Php 如何在运行Phing target命令之前设置环境变量

Php 如何在运行Phing target命令之前设置环境变量,php,build,build-process,phing,Php,Build,Build Process,Phing,我一直在尝试转换在bash中运行的命令,以使用Phing启动resque使用者,但在执行php命令之前,我找不到设置环境变量的方法 这是我试图转换的命令: APPLICATION_ENV=dev VVERBOSE=1 QUEUE=myqueue APP_INCLUDE=app/cli/bootstrap.php php composer/chrisboulton/php-resque/resque.php 我试过: <!-- Resque start consumer --> &l

我一直在尝试转换在bash中运行的命令,以使用Phing启动resque使用者,但在执行php命令之前,我找不到设置环境变量的方法

这是我试图转换的命令:

APPLICATION_ENV=dev VVERBOSE=1 QUEUE=myqueue APP_INCLUDE=app/cli/bootstrap.php php composer/chrisboulton/php-resque/resque.php
我试过:

<!-- Resque start consumer -->
<target name="start_resque_consumer" description="Spans a resque consumer">
    <property environment="APPLICATION_ENV" value="dev"/>
    <property environment="VVERBOSE" value="1"/>
    <property environment="QUEUE" value="myqueue"/>
    <property environment="APP_INCLUDE" value="${project.basedir}/app/cli/bootstrap.php"/>
    <exec executable="php" checkreturn="true" passthru="true" dir="${project.basedir}/composer/chrisboulton/php-resque">
        <arg line="resque.php"/>
    </exec>
</target>

以及:


你知道我该怎么做吗?甚至可以使用Phing设置环境变量吗?

尝试以下方法:

<target name="start_resque_consumer" description="Spans a resque consumer">
    <exec executable="php" checkreturn="true" passthru="true" dir="${project.basedir}/composer/chrisboulton/php-resque">
        <arg value="${project.basedir}/composer/chrisboulton/php-resque/resque.php" />
        <env key="VVERBOSE" value="1" />
        <env key="QUEUE" value="myqueue" />
        <env key="APP_INCLUDE" value="${project.basedir}/app/cli/bootstrap.php" />
    </exec>
</target>

在脚本之前使用
env
命令

<!-- Here are the initial data, under .gitignore -->
<property file="build/secret/local.ini"/>
<!-- Let's create some shortcuts -->
<property name="local.mysql.connect" value="-h${local.mysql.host} -P${local.mysql.port} -u${local.mysql.user}"/>
<property name="local.mysql.env" value="env MYSQL_PWD=${local.mysql.password}"/>

<target name="some_target">
    <!-- Tens of them. "The password in command line" warning finally silenced. It can be put in cron ! -->
    <exec
        command="${local.mysql.env} mysql ${local.mysql.connect} ${local.mysql.database.target} &lt; ./sql/some_script.sql"
    />
</target>


我想你是对的@shanetheat可能是重复的。不幸的是,对我来说,这意味着没有办法做到这一点:(您可以创建包含这些环境变量值的不同属性文件,确保不在版本控制中跟踪它们。然后每个环境都有自己的属性文件。不会回答您的问题,但会根据您的特殊需要得到类似的结果。我得到
phing.tasks.system.ExecTask不支持rt“env”创建者/加法器。
env
标记不存在,由文档确认:
<!-- Here are the initial data, under .gitignore -->
<property file="build/secret/local.ini"/>
<!-- Let's create some shortcuts -->
<property name="local.mysql.connect" value="-h${local.mysql.host} -P${local.mysql.port} -u${local.mysql.user}"/>
<property name="local.mysql.env" value="env MYSQL_PWD=${local.mysql.password}"/>

<target name="some_target">
    <!-- Tens of them. "The password in command line" warning finally silenced. It can be put in cron ! -->
    <exec
        command="${local.mysql.env} mysql ${local.mysql.connect} ${local.mysql.database.target} &lt; ./sql/some_script.sql"
    />
</target>