Reputation: 342
We are trying to deploy a symfony2 application on bluemix, without success... We have seen a few posts about this kind of issue, but they are either without answer, or obsoletes, or with a slightly different issue.
We have a symfony application, based on the symfony standard edition distribution, moved in a backend folder because we also have a frontend. However, the composer.json is in the root directory, and references the backend folder. This is the only modification done.
Everything works fine locally, but not on Bluemix with the PHP buildpack, here is the error :
Generating autoload files
[RuntimeException]
Could not scan for classes inside "backend/app/AppKernel.php" which does not appear to be a file nor a folder
On Bluemix the env is set to prod through the manifest.yml, and we have tried the composer install in the same configuration locally:
applications:
- name: myapp
random-route: true
memory: 128M
env:
SYMFONY_ENV: prod
#BP_DEBUG: true
This error is the one I get with verbose mode, and I have exactly the same without verbose mode. We run in no-dev mode on Bluemix, here is the full options.json:
{
"COMPOSER_INSTALL_OPTIONS": [ "--no-dev", "-vvv"]
}
I have attempted to add scripts for debugging purpose. It works well locally but not on Bluemix, so it does not help at all. Extract from composer.json:
"scripts": {
"pre-autoload-dump": [
"echo TEST"
],
...
}
The file exists and is in the right place:
$ ll backend/app/
total 128
drwxr-xr-x 6 bob bob 4096 févr. 28 15:45 .
drwxr-xr-x 9 bob bob 4096 févr. 28 15:44 ..
-rwxr-xr-x 1 bob bob 101 févr. 23 11:37 AppCache.php
-rwxr-xr-x 1 bob bob 1394 févr. 24 11:32 AppKernel.php
-rwxr-xr-x 1 bob bob 263 févr. 23 11:37 autoload.php
-rw-r--r-- 1 bob bob 40956 févr. 28 15:45 bootstrap.php.cache
drwxr-xr-x 3 bob bob 4096 févr. 28 15:45 cache
-rwxr-xr-x 1 bob bob 3909 févr. 28 15:45 check.php
drwxr-xr-x 2 bob bob 4096 févr. 28 14:37 config
-rwxr-xr-x 1 bob bob 897 févr. 22 15:28 console
-rwxr-xr-x 1 bob bob 143 févr. 23 11:37 .htaccess
drwxr-xr-x 2 bob bob 4096 févr. 28 14:37 logs
-rwxr-xr-x 1 bob bob 1358 févr. 23 11:37 phpunit.xml.dist
drwxr-xr-x 3 bob bob 4096 févr. 23 11:37 Resources
-rwxr-xr-x 1 bob bob 34272 févr. 28 15:45 SymfonyRequirements.php
It seems like the configuration is correct (looking for the right place) in the composer.json. The same file is used locally without any issue:
"extra": {
"symfony-app-dir": "backend/app",
"symfony-web-dir": "backend/web",
...
}
Last thing I have in mind is that I did a cf delete myapp before doing a new cf push just to be sure the latest files are taken into account on Bluemix (because I don't understand why the pre-autoload-dump scripts are not run on Bluemix)
Thanks for the help!
Upvotes: 1
Views: 333
Reputation: 342
I have found the issue.
First, I found it by doing this:
I have added the no-script and no-autoloader option to composer, to make sure that the container will run and I'm able to connect to it to see the filesystem. Without that, the container is destroyed and there's no way to know what happened.
"COMPOSER_INSTALL_OPTIONS_DEBUG": [ "--no-dev", "-vvv", "--no-autoloader", "--no-scripts"]
Then I have connected to the container with ssh (only with Diego):
cf enable-ssh
cf ssh
Then, by looking at the filesystem, I found out that the backend and frontend folders are put in an htdocs folder.
I have changed my composer.json to reference htdocs/backend/ instead of just backend/ and everything works fine. Sample from the composer.json file:
"autoload": {
"psr-4": { "": "htdocs/backend/src/" },
"classmap": [ "htdocs/backend/app/AppKernel.php", "htdocs/backend/app/AppCache.php" ]
},
The issue now is that I have a different behavior between the local environment (everything is in ./) and the container (everything is in htdocs/), and composer.json not supporting environment variables makes it complicated to use only one file. But that's another story.
Upvotes: 2