如何在不更改代码的情况下为Symfony2设置php CLI版本? [英] How can I set the php CLI version for Symfony2 without changing the code?

查看:65
本文介绍了如何在不更改代码的情况下为Symfony2设置php CLI版本?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的设置

  • 共享托管
  • 无root访问权限
  • shell访问
  • symfony 2.1
  • 部署所需的能力(至少,这就是计划)

build_bootstrap.php使用

#!/usr/bin/env php

这与php4 cli中的链接

This is linked to the php4 cli in

/usr/local/bin/php

PHP4当然不起作用. php 5.3 cli在

PHP4 does of course not work. The php 5.3 cli is in

/usr/local/bin/php53 

是否有一个中心位置可以告诉Symfony 2.1更改环境?与putenv有关系吗?导出bash配置文件中的路径?

Is there a central place to tell Symfony 2.1 to change the env? Something with putenv? Export path in bash config files?

更新:

我现在在bashrc中使用php的别名,如@thecatontheflat建议.

I am now using an alias for php in my bashrc as @thecatontheflat suggested.

不幸的是,Symfony在寻找php二进制文件的地方引入了自己的逻辑. 一种选择是通过putenv设置PHP_PATH. 我将其添加到app/console和app/autoload.php中,因为这两个文件都参与了Capifony任务

Unfortunately Symfony brings its own logic where to look for the php binaries. One option is to set PHP_PATH via putenv. I added it both to app/console and app/autoload.php as both files are involved in the Capifony tasks

推荐答案

解决方案:

将两个设置添加到.bashrc/.bash_profile

add two settings to .bashrc/.bash_profile

alias php="/usr/local/bin/php53"
export PHP_PATH = "/usr/local/bin/php53"

并在Capifony的deploy.rb中设置php_bin

and also set php_bin in Capifony's deploy.rb

set  :php_bin, " /usr/local/bin/php53"

这篇关于如何在不更改代码的情况下为Symfony2设置php CLI版本?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆