运行 phing 中的 php 脚本
running a php script inside phing
我正在尝试使用 phing 来自动化我在工作中执行的某些流程。目前,我正在尝试 运行 我拥有的 php 脚本,但是当我 运行 phing 时,屏幕上没有任何输出。这是我的 build.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project name="projectName" basedir="." default="release">
<target name="release">
<exec command="php path/to/script/script.php hi" escape="false"/>
</target>
</project>
这是 script.php 目前正在做的事情:
<?php
print_r($argv);
当我 运行 phing 时,我希望它打印命令行参数(只是一个确保一切正常工作的测试),但我没有在屏幕上得到任何输出。我在用这个做些什么吗?我正在使用 php 7.1.4 和 phing 2.16.0
您忘记了 passthru 属性,所以您可以看到脚本的输出
试试这个:
<?xml version="1.0" encoding="UTF-8"?>
<project name="projectName" basedir="." default="release">
<target name="release">
<exec command="php path/to/script/script.php hi" escape="false" passthru="true" />
</target>
</project>
因为另一个答案有错误我把更正的代码放在这里:
<project name="projectName" default="release">
<target name="release">
<exec command="php path/to/script/script.php hi"
escape="false"
passthru="true"/>
</target>
</project>
注意 从 Phing 3.x 开始,exec
任务的 command
属性已弃用。
鼓励使用 arg
元素代替:
<?xml version="1.0" encoding="UTF-8"?>
<project name="exec" basedir="." default="main">
<target name="main">
<exec executable="php" passthru="true">
<arg file="path/to/script/script.php"/>
<arg value="hi"/>
</exec>
</target>
</project>
我正在尝试使用 phing 来自动化我在工作中执行的某些流程。目前,我正在尝试 运行 我拥有的 php 脚本,但是当我 运行 phing 时,屏幕上没有任何输出。这是我的 build.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<project name="projectName" basedir="." default="release">
<target name="release">
<exec command="php path/to/script/script.php hi" escape="false"/>
</target>
</project>
这是 script.php 目前正在做的事情:
<?php
print_r($argv);
当我 运行 phing 时,我希望它打印命令行参数(只是一个确保一切正常工作的测试),但我没有在屏幕上得到任何输出。我在用这个做些什么吗?我正在使用 php 7.1.4 和 phing 2.16.0
您忘记了 passthru 属性,所以您可以看到脚本的输出
试试这个:
<?xml version="1.0" encoding="UTF-8"?>
<project name="projectName" basedir="." default="release">
<target name="release">
<exec command="php path/to/script/script.php hi" escape="false" passthru="true" />
</target>
</project>
因为另一个答案有错误我把更正的代码放在这里:
<project name="projectName" default="release">
<target name="release">
<exec command="php path/to/script/script.php hi"
escape="false"
passthru="true"/>
</target>
</project>
注意 从 Phing 3.x 开始,exec
任务的 command
属性已弃用。
鼓励使用 arg
元素代替:
<?xml version="1.0" encoding="UTF-8"?>
<project name="exec" basedir="." default="main">
<target name="main">
<exec executable="php" passthru="true">
<arg file="path/to/script/script.php"/>
<arg value="hi"/>
</exec>
</target>
</project>