I answered my own question. I just needed to add this right above the phpcodesniffer line above:
<exec command="export PATH=./bin:$PATH" />
Question
I have a PHP app that is getting its dependencies installed with Composer. Composer puts the binaries in the bin folder. I want to use Phing to execute some tests on my code, but Phing isn't finding the apps installed in {basedir}/bin/.
For example, this works:
<exec command="./bin/phpcs --standard=zend ." passthru="true"></exec>
But this fails:
<phpcodesniffer standard="ZEND" />
The Phing error message basically says that phpcs is not installed. How do I tell Phing to run the binary from the bin directory when using the built-in task for phpcodesniffer (which has nicer outputs than the exec example above)?
Solution
I answered my own question. I just needed to add this right above the phpcodesniffer line above:
<exec command="export PATH=./bin:$PATH" />
OTHER TIPS
In case anyone wonders, it's also possible to add Composer's autoload into Phing's autoload routine. With something like next line
<autoloader autoloaderpath="${project.basedir}/vendor/autoload.php"/>
This would allow Phing to "see" all the dependencies served with composer.
You could also use the includepath
task to prepend (by default) a path to the include_path similar to export PATH=./bin:$PATH
<includepath classpath="./bin" />