0

While writing a phing xml code to build a php project. Is there any way to find errors in particular project file using phing xml.

We found the code as below only throw alert for syntax error we need to filter it for all php errors like fatal errors & warnings & syntax errors.

the code as below :

  <target name="build">

    <apply executable="php" failonerror="true">
        <arg value="-l" />
        <fileset dir="${srcDir}">
            <include name="**/*.php" />
        </fileset>
    </apply>

 </target>
Abdul Vahaf
  • 360
  • 2
  • 5
  • 10

2 Answers2

0

Firstly, I'd check out the PhpLintTask instead of running php -l to lint your code. Secondly, the only way to pick up run time errors is to actually run your code. Maybe have a look at using phpunit or Codeception for acceptance testing?

Nev Stokes
  • 9,051
  • 5
  • 42
  • 44
0

This is the code to validate php syntax & fatal error while creating build and stop the build if has any error.

<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>
Abdul Vahaf
  • 360
  • 2
  • 5
  • 10