简体   繁体   中英

How can I composer update on OpenShift?

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

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 文档,您可以通过创建标记文件在每次构建后启用composer install

touch .openshift/markers/use_composer

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM