本文介绍了Phing exec命令设置环境变量的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我试图在使用phing的构建脚本中设置环境变量。
这通常是这样的命令行:

  export MY_VAR = value 



在Phing我做了以下但是不工作。

 < exec command =export MY_VAR = value/> 


解决方案

em>没有办法在PHP中设置/导出(Unix)shell变量,以便在启动php脚本的范围内可见。

  php myfile.php(putenv或shell_exec('export foo = bar');)
echo $ foo

将不返回任何内容。
因为PHP不能这样做,所以既不能phing。



访问shell环境变量跨多个脚本运行(如果它是你想要的)似乎也像非理性的设计决定,漂亮的状态。



除此之外,我敦促你坚持phing和学习它的精益课。 Phing在一定程度上有助于无国籍人的思考。


I'm trying to set an environment variable in a build script with phing.This is normally done command line like this:

export MY_VAR=value

In Phing I did the following but it isn't working.

<exec command="export MY_VAR=value" />
解决方案

Bold claim: There is no way to set/export a (Unix) shell variable in PHP so that it is visible inside the scope that started the php script.

php myfile.php (does putenv or shell_exec('export foo=bar');)
echo $foo

Will return nothing.As PHP can not do it so neither can phing.

Accessing shell environment variables accross multiple script runs (if its that what you want) seems also like an unideal design decision, pretty stateful.

Apart from that I'd urge you to stick to phing and learn its lean lesson. Phing helps stateless thinking to some degree.

这篇关于Phing exec命令设置环境变量的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-14 14:30