Logo Questions Linux Laravel Mysql Ubuntu Git Menu

How to run (or should I run) Composer on Openshift?

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
root/runtime/repo/init_autoloader.php:51 Stack trace: #0
root/runtime/repo/public/index.php(18): require() #1 {main} thrown in
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.

like image 897
Jérôme Verstrynge Avatar asked Mar 15 '23 09:03

Jérôme Verstrynge

1 Answers

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.


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




if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
    curl -s https://getcomposer.org/installer | php -- --install-dir=$OPENSHIFT_DATA_DIR
    php $OPENSHIFT_DATA_DIR/composer.phar self-update

( unset GIT_DIR ; cd $OPENSHIFT_REPO_DIR ; php $OPENSHIFT_DATA_DIR/composer.phar install )
like image 87
Jens A. Koch Avatar answered Mar 18 '23 04:03

Jens A. Koch