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, using action_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
:
#!/bin/bash
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer"
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
curl -s https://getcomposer.org/installer | php -- --install-dir=$OPENSHIFT_DATA_DIR
else
php $OPENSHIFT_DATA_DIR/composer.phar self-update
fi
( unset GIT_DIR ; cd $OPENSHIFT_REPO_DIR ; php $OPENSHIFT_DATA_DIR/composer.phar install )
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With