I am trying to create ZendFramework's Skeleton application on Openshift. I have created a PHP5 application using these instructions and cloned it locally. I cloned the ZendFramework skeleton application in the repository, then ran Composer to install dependencies locally.
I then pushed my repository to Openshift, but I get the following error message:
Fatal error: Uncaught exception 'RuntimeException' with message
'Unable to load ZF2. Run `php composer.phar install`
or define a ZF2_PATH environment variable.' in
/var/lib/openshift/559d4d8f500446844700002b/app-
root/runtime/repo/init_autoloader.php:51 Stack trace: #0
/var/lib/openshift/559d4d8f500446844700002b/app-
root/runtime/repo/public/index.php(18): require() #1 {main} thrown in
/var/lib/openshift/559d4d8f500446844700002b/app-
root/runtime/repo/init_autoloader.php on line 51
which is indicative that I need to run Composer on Openshift. How do I achieve this?
In my local repository, the /vendor
directory is filled with dependency directories. However, /vendor
is ignored in the commit. I could try to commit and push it, but is this the right way to proceed? It does not look clean.
Basically, you need to execute
composer install
with each build automatically on OpenShift.You might do this by adding a marker file named
use_composer
in the folder.openshift/markers
..openshift/markers/use_composer
Referencing: https://developers.openshift.com/en/php-markers.html
If you need to do more than just
composer install
, like installing Composer, usingaction_hooks
is the better choice. They allow to work with bash scripts.See, https://developers.openshift.com/en/managing-action-hooks.html
.openshift/action_hooks/build
:The best way to install dependencies is from an action hook, i.e. a script run by the cartridge during the deployment. I would use the
deploy
hook:Also remember to make this script executable:
chmod +x .openshift/action_hooks/deploy
.