问题描述
我正在尝试在Openshift上创建ZendFramework的Skeleton应用程序.我已经使用这些指令创建了一个PHP5应用程序,并将其本地克隆.我在存储库中克隆了ZendFramework骨架应用程序,然后运行Composer在本地安装依赖项.
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.
然后我将存储库推送到Openshift,但收到以下错误消息:
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
/var/lib/openshift/559d4d8f500446844700002b/app-
root/runtime/repo/init_autoloader.php:51 Stack trace: #0
/var/lib/openshift/559d4d8f500446844700002b/app-
root/runtime/repo/public/index.php(18): require() #1 {main} thrown in
/var/lib/openshift/559d4d8f500446844700002b/app-
root/runtime/repo/init_autoloader.php on line 51
这表明我需要在Openshift上运行Composer.我该如何实现?
which is indicative that I need to run Composer on Openshift. How do I achieve this?
在我的本地存储库中,/vendor
目录中充满了依赖项目录.但是,在提交中将忽略/vendor
.我可以尝试提交并推动它,但这是正确的进行方式吗?看起来不太干净.
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.
推荐答案
基本上,您需要在OpenShift上自动对每个构建执行composer install
.
Basically, you need to execute composer install
with each build automatically on OpenShift.
您可以通过在文件夹.openshift/markers
中添加名为use_composer
的标记文件来实现.
You might do this by adding a marker file named use_composer
in the folder .openshift/markers
.
.openshift/markers/use_composer
引用: https://developers.openshift.com/en/php-markers. html
如果您不仅需要执行composer install
以外的其他功能,例如安装Composer,则使用action_hooks
是更好的选择.它们允许使用bash脚本.
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.
请参见 https://developers.openshift.com/en/managing- action-hooks.html
.openshift/action_hooks/build
:
#!/bin/bash
export COMPOSER_HOME="$OPENSHIFT_DATA_DIR/.composer"
if [ ! -f "$OPENSHIFT_DATA_DIR/composer.phar" ]; then
curl -s https://getcomposer.org/installer | php -- --install-dir=$OPENSHIFT_DATA_DIR
else
php $OPENSHIFT_DATA_DIR/composer.phar self-update
fi
( unset GIT_DIR ; cd $OPENSHIFT_REPO_DIR ; php $OPENSHIFT_DATA_DIR/composer.phar install )
这篇关于如何在Openshift上运行(或应该运行)Composer?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!