How can I composer update on OpenShift?

筅森魡賤 提交于 2019-12-07 14:58:40

问题


I am trying to use Slim on OpenShift with a free node. I can run composer update from the SSH sessions without any problem.

The only problem is every time I want to commit files through git I have to go to the console and run composer install again. My question is there is any easy way to workaround this? I tried a BASH script in /project/.openshift/action_hooks/post_deploy but the server is not creating the vendor folder under runtime/repo


回答1:


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

  • Openshift builds
  • Openshift Default Build Lifecycle



回答2:


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


来源:https://stackoverflow.com/questions/31026031/how-can-i-composer-update-on-openshift

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