0
votes

I am trying to use phing to automate some of the processes I do at work. Currently, I am trying to run a php script I have, but nothing is output to the screen when I run phing. Here is my build.xml file:

<?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>

and here is what script.php is currently doing:

<?php

print_r($argv);

when I run phing, I expect it to print the command line arguments (just a test to make sure things are working properly), but instead I don't get anything output to the screen. Am I doing something wring with this? I am using php 7.1.4 and phing 2.16.0

3

3 Answers

0
votes

Because there's an error in another answer I put the corrected code here:

<project name="projectName" default="release">
    <target name="release">
        <exec command="php path/to/script/script.php hi" 
              escape="false" 
              passthru="true"/>
    </target>
</project>
0
votes

You forgot the passthru attribute, so you can see the output of your script

Try this:

<?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>
0
votes

Note As of Phing 3.x the command attribute of the exec task is deprecated.

It is encouraged to use arg elements instead:

<?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>