PHPDaemon\Core\ShellCommand::exec PHP Method

exec() public static method

Execute
public static exec ( string $binPath = null, callable $cb = null, array $args = null, array $env = null )
$binPath string Binpath
$cb callable Callback
$args array Optional. Arguments
$env array Optional. Hash of environment's variables
    public static function exec($binPath = null, $cb = null, $args = null, $env = null)
    {
        $o = new static();
        $data = '';
        $o->bind('read', function ($o) use(&$data, $o) {
            $data .= $o->readUnlimited();
        });
        $o->bind('eof', function ($o) use(&$data, $cb) {
            $cb($o, $data);
            $o->close();
        });
        $o->execute($binPath, $args, $env);
    }