I need to run composer.phar update from a web controller.
I can run all kinds of regular commands in this way (ls, cp, etc) but when I invoke the phar file I get empty output.
The code I have looks like this:
class Maintenance_Controller
{
public function do_maintenance()
{
echo exec("/usr/bin/env php composer.phar", $out, $ret);
var_dump($out); // outputs -> array()
var_dump($ret); // outputs -> int(127)
}
}
127 indicates a bad path, but I am sure I'm in the right directory.
Also, this works when using a php_cli wrapper, so maybe it has to do with the www-data user? chmod 777 does not help, and I hate to do that anyway.
I have also used passthru(), system() and the backtic syntax. I am unable to get to the reason this doesn't work. I can't seem to interrogate the stderr or stdout from the exec() call beyond the 127 code.
Obvious Question:
What am I doing wrong?
Better Question:
Is there a better way to interrogate and execute .phar files from within a script?