php-buildpack with composer

188 views
Skip to first unread message

miguelf...@gmail.com

unread,
Feb 9, 2015, 10:22:21 AM2/9/15
to vcap...@cloudfoundry.org
Hello,
I am trying to push a php project using the php-buildpack (https://github.com/cloudfoundry/php-buildpack). I am using composer to install dependencies. when I run composer install on my composer.json locally it creates a vendor folder containing all my dependencies, but when I cf push the project using the buildpack the composer install runs but no vendor folder is created. So all my dependencies are lost. I have looked through the files after the push and I cannot find the vendor directory anywhere. this works perfectly locally and the files are identical. has anyone experienced a similar problem? 

Thanks

Daniel Mikusa

unread,
Feb 9, 2015, 10:42:47 AM2/9/15
to vcap...@cloudfoundry.org
On Mon, Feb 9, 2015 at 10:22 AM, <miguelf...@gmail.com> wrote:
Hello,
I am trying to push a php project using the php-buildpack (https://github.com/cloudfoundry/php-buildpack). I am using composer to install dependencies. when I run composer install on my composer.json locally it creates a vendor folder containing all my dependencies, but when I cf push the project using the buildpack the composer install runs but no vendor folder is created.

What's your intent here?  Are you trying to vendor the dependencies locally and push them with your app?  Or do you not want to push them and let them install server side?
 
So all my dependencies are lost. I have looked through the files after the push and I cannot find the vendor directory anywhere.

How are you doing this?  `cf files`?
 
this works perfectly locally and the files are identical. has anyone experienced a similar problem? 

Can you also include the output of `cf push`?

Dan
 

Thanks

--
You received this message because you are subscribed to the Google Groups "Cloud Foundry Developers" group.
To view this discussion on the web visit https://groups.google.com/a/cloudfoundry.org/d/msgid/vcap-dev/afcff93f-028a-432c-a273-6aaff6567494%40cloudfoundry.org.

To unsubscribe from this group and stop receiving emails from it, send an email to vcap-dev+u...@cloudfoundry.org.

miguelf...@gmail.com

unread,
Feb 9, 2015, 11:08:04 AM2/9/15
to vcap...@cloudfoundry.org, dmi...@pivotal.io
Thanks for the quick reply,

My intent is to push the composer.json and have all the dependencies be installed server side. 

I browse the server side files using the ibm bluemix ui.  
here is a screenshot:
I have an ls command running before and after the composer install, to get an idea of what files are there. thats where

composer.json

composer.lock

htdocs

httpd

logs

mu-plugins

php

wp-config.php

comes from




Daniel Mikusa

unread,
Feb 9, 2015, 11:56:10 AM2/9/15
to vcap...@cloudfoundry.org
It's a little hard to tell what's going on from that, some thoughts.

1.) You've got composer installing some wordpress extensions.  That uses a custom composer installer, so it might be putting files elsewhere.  It'd be helpful to see your composer.json file.

2.) Do you have a manifest.yml file?  Are you setting any environment variables there?

3.) Do you have a `.bp-config/options.json` file?  If so, include it.

4.) Try #3 from this link and include the output.


5.) Try using master and see if this is something that's been recently fixed.  The build pack has been pretty active over the last month or two, fixing and improving things.

Dan

miguelf...@gmail.com

unread,
Feb 9, 2015, 12:49:57 PM2/9/15
to vcap...@cloudfoundry.org, dmi...@pivotal.io
here is my composer.json:
{
    "repositories": [
        {
          "type": "composer",
          "url": "https://packages.zendframework.com/"
        },
        {
          "type": "composer",
          "url": "http://wpackagist.org"
        },
        {
          "type": "vcs",
          "url": "g...@github.com:ibmjstart/ZendService_IBMObjectStorage.git"
        },
        {
          "type": "vcs",
          "url": "g...@github.com:ibmjstart/wp-bluemix-sendgrid.git"
        },
        {
          "type": "vcs",
          "url": "g...@github.com:ibmjstart/wp-bluemix-objectstorage.git"
        }
    ],
    
    "scripts": {
        "pre-install-cmd" : [
            "ls"
        ],
        "post-install-cmd" : [
            "ls",
            "mv mu-plugins htdocs/wp-content/mu-plugins",
            "mv .user.ini htdocs",
            "curl https://api.github.com/rate_limit"
        ]
        
    },

    "require": {
        "ext-gd"                                      : "*",
        "ibmjstart/wp-bluemix-sendgrid"               : "dev-master",
        "ibmjstart/wp-bluemix-objectstorage"          : "dev-miguel",
        "wpackagist-plugin/stops-core-theme-and-plugin-updates": "*",
        "wpackagist-plugin/sendgrid-email-delivery-simplified": "*",
        "wpackagist-plugin/w3-total-cache"            : "*",
        "wpackagist-theme/twentyfourteen"             : "*",
        "wpackagist-theme/twentythirteen"             : "*",
        "wpackagist-theme/twentytwelve"               : "*"
    },

    "extra": {
      "wordpress-install-dir": "htdocs",
      "installer-paths": {
        "htdocs/wp-content/plugins/{$name}/" : ["type:wordpress-plugin"],
        "htdocs/wp-content/themes/{$name}/"  : ["type:wordpress-theme"]
      }
    },
    "minimum-stability" : "dev",
    "prefer-stable": true
}

I do have plugins that have their own dependencies that install to vendors, and they all get correctly installed there when I run "composer install" locally (leads me to believe they are not the issue). when composer runs during the push no vendor file seems to be created. I do not have a manifest, but I do use .bp-config/options.json here it is
{
  "PHP_EXTENSIONS": ["bz2", "zlib", "curl", "mcrypt", "mbstring", "mysqli", "gd", "zip"],
  "PHP_VERSION": "PHP_54_LATEST",
  "LIBDIR":"/htdocs"
}

there is also a httpdd/extra/httpd-php.conf in there with options.json (not sure if that matters)

I'll try using master for the build pack now and report if anything happens. Again thank you very much for your help! I've been working on this issue for quite a while

Daniel Mikusa

unread,
Feb 9, 2015, 2:25:22 PM2/9/15
to miguelf...@gmail.com, vcap...@cloudfoundry.org
A couple things with this.

1.) Remove the leading slash.  Not sure if that would be causing problem, but it's not necessary.

2.) Don't set the LIBDIR to point to the WEBDIR.  The idea of the LIBDIR is a place where you can put files that your application needs, but that you do not want to be public.  The build pack automatically adds LIBDIR to the include_path, so things you put there can easily include / require'd in your apps.

If you're trying to change where Composer installs things, you want to set `COMPOSER_VENDOR_DIR`.  Setting it to `{BUILD_DIR}/vendor` should give you a vendor directory at the root of your application.


}

there is also a httpdd/extra/httpd-php.conf in there with options.json (not sure if that matters)

That shouldn't affect Composer.  Do keep any eye on this though, as the build pack has recently made some changes in this area.



I'll try using master for the build pack now and report if anything happens. Again thank you very much for your help! I've been working on this issue for quite a while

No problem.  If you have a test app that replicates the behavior, feel free to attach it.  I'd be happy to give it a try and debug further.

Dan

miguelf...@gmail.com

unread,
Feb 9, 2015, 3:34:14 PM2/9/15
to vcap...@cloudfoundry.org, miguelf...@gmail.com, dmi...@pivotal.io
I think you may have solved it, I see a vendor directory showing up now after composer install. this is a big step in the right direction! just one problem now. after dependencies are installed I'm getting 

ERR bash: composer: command not found (screenshot attached)

this happens after composer installs all dependencies so it is pretty weird that it's saying it doesnt recognize composer. have you seen this issue before? I've tried different buildpack versions, same error. this has been happening all day so I don't think it was cause by changing COMPOSER_VENDOR_DIR in options.json

Screen Shot 2015-02-09 at 3.28.07 PM.png

miguelf...@gmail.com

unread,
Feb 9, 2015, 4:07:24 PM2/9/15
to vcap...@cloudfoundry.org, miguelf...@gmail.com, dmi...@pivotal.io
fixed it by pushing to a new app, not really a great fix, but it worked. thanks for the help. I should hopefully be able to handle it from here

Daniel Mikusa

unread,
Feb 9, 2015, 4:11:39 PM2/9/15
to miguelf...@gmail.com, vcap...@cloudfoundry.org
Glad to hear you got everything fixed up!

Not really sure what's happening with the "composer not found" error based on the output you captured.  If you still have the old app and can repro the problem, set the env variable BP_DEBUG to `True` with `cf set-env` or in your manifest and push again.  That should generate debug output from the build pack and it will likely give us some clues as to what happened.

Dan

miguelf...@gmail.com

unread,
Feb 10, 2015, 5:53:09 PM2/10/15
to vcap...@cloudfoundry.org, miguelf...@gmail.com, dmi...@pivotal.io
I haven't been able to replicate the unrecognized composer error I'm guessing it was something on our end, but I'll send you the debug logs if I see it again. One thing we have noticed though is that we set "PHP_VERSION": "PHP_55_LATEST", and get this error:

[WARNING] helpers - Selected version of PHP [PHP_55_LATEST] not available.  Defaulting to the latest version [5.4.36] 

this doesn't cause any problems for me because 5.4 works fine. just wanted to let you know.

thanks again for all the help!

Daniel Mikusa

unread,
Feb 11, 2015, 9:18:47 AM2/11/15
to miguel clement, vcap...@cloudfoundry.org
On Tue, Feb 10, 2015 at 5:53 PM, <miguelf...@gmail.com> wrote:
I haven't been able to replicate the unrecognized composer error I'm guessing it was something on our end, but I'll send you the debug logs if I see it again.

Thanks!
 
One thing we have noticed though is that we set "PHP_VERSION": "PHP_55_LATEST", and get this error:

[WARNING] helpers - Selected version of PHP [PHP_55_LATEST] not available.  Defaulting to the latest version [5.4.36] 

It should be "PHP_VERSION": "{PHP_55_LATEST}".  The "{..}" are important.  They indicate to the build pack that it should substitute the value of PHP_55_LATEST (like 5.5.21) here, whereas no curly braces means use the literal value "PHP_55_LATEST" which is not a valid version.

Dan
Reply all
Reply to author
Forward
0 new messages