I want to run a task in Phing where I first run the PHP server and then run a PHP Unit test.
This is what I have so far:
<target name="test">
<!-- Run the PHP server -->
<exec executable="php">
<arg line="-S localhost:81 server.php"/>
</exec>
<!-- Run my tests -->
<exec executable="${phpunit.bin}" dir="${test.dir}" passthru="true" returnProperty="test.result">
<arg line="IntegrationTests"/>
</exec>
<!-- Check if succeeded -->
<condition property="test.succeeded">
<equals arg1="${test.result}" arg2="0"/>
</condition>
<fail unless="test.succeeded" message="Unit Tests Failed"/>
</target>
The issue is that Phing hangs after creating the PHP server.
The issue is solved by adding the spawn property like so:
<exec executable="php" spawn="true">
This works as expected, except that the process never actually exits even after Phing exits. In other words, the PHP server is still running long after the Phing has completed it's tasks.
Therefore my question is how to properly run a php server in the background in Phing?