How can I update composer in OpenShift?
I am trying to use Slim on OpenShift with free node. I can run composer update
from SSH sessions without any problem.
The only problem is every time I want to write files via git, I have to go to the console and run again composer install
. My question is, is there an easy workaround for this? I tried BASH script at /project/.openshift/action_hooks/post_deploy but server does not create vendor folder in runtime / repo
source to share
I always do this via action hooks :
Inside the project directory, I have a script called /project/.openshift/action_hooks/post_deploy
where post_deploy is a bash script. This is what I used:
#!/bin/bash
export MY_PHPCOMPOSER=$OPENSHIFT_DATA_DIR/composer.phar
# if composer not exists, download
if [ ! -f $MY_PHPCOMPOSER ]; then
cd $OPENSHIFT_DATA_DIR
echo "Downloading composer..."
php -r "readfile('https://getcomposer.org/installer');" | php
fi
$MY_PHPCOMPOSER -n -q self-update
cd $OPENSHIFT_REPO_DIR
# install
php -dmemory_limit=1G $MY_PHPCOMPOSER install
So the post_deploy script will execute every time you push your repo to openhit. It works like a charm!
Side note
Since the OpenShift version is not always updated, download a new copy of the composer and use it. Also, don't forget to adjust your permission settings.
useful links
source to share
I know my answer is delayed, but according to the Openshift documentation, you can include composer install
after each build by simply creating a token file
touch .openshift/markers/use_composer
source to share