同时编写phing xml代码来构建php项目。有没有办法使用phing xml来查找特定项目文件中的错误。
我们发现下面的代码只对语法错误抛出警告,我们需要过滤所有php错误,比如致命错误、警告和语法错误。
代码如下:
<target name="build">
<apply executable="php" failonerror="true">
<arg value="-l" />
<fileset dir="${srcDir}">
<include name="**/*.php" />
</fileset>
</apply>
</target>发布于 2013-12-04 19:00:42
首先,我会检查PhpLintTask,而不是运行php -l来嵌入代码。其次,拾取运行时错误的唯一方法是实际运行代码。也许可以考虑使用phpunit或Codeception进行验收测试?
发布于 2013-12-05 20:05:14
这是用来验证php语法的代码&创建构建时出现致命错误,如果有错误就停止构建。
<target name="build">
<foreach param="fname" absparam="abs-fname" target="cat">
<fileset dir="${srcDir}">
<include name="**/*.php" />
</fileset>
</foreach>
</target>
<target name="cat">
<exec command="php -f ${abs-fname}" checkreturn="true" output="output_text.txt" />
</target>https://stackoverflow.com/questions/20369775
复制相似问题