How can I composer update on OpenShift?

三世轮回 提交于 2019-12-05 21:49:43

I always do it via action hooks:

Inside my project directory I have a script called by /project/.openshift/action_hooks/post_deploy where post_deploy is a bash script. Here goes what I have been using:

#!/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 post_deploy script will perform every time which you push your repo to openshit. It work like a charm!

Side note

Since not always the OpenShift composer's version is updated it's safe to download a new composer copy and use it. Also, don't forget adjusting permissions settings.

Helpful links

I know that my answer is late but according to the Openshift documentation you can enable composer install after each build by just creating a marker file:

touch .openshift/markers/use_composer
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!