tomaszdurka / php-exec
此包最新版本(0.1.1)没有可用的许可证信息。
0.1.1
2014-09-16 16:06 UTC
Requires
- evenement/evenement: ~2.0.0
Requires (Dev)
- phpunit/phpunit: ~4.1.3
- tomaszdurka/mocka: ~0.8.1
This package is auto-updated.
Last update: 2024-08-26 12:33:46 UTC
README
PhpExec
这是一个用于在PHP中执行shell命令的超级简单的库。我是不知道已经成熟的(满足我的需求)库 https://github.com/symfony/Process 而创建它的。
安装
使用composer
{ "require": { "tomaszdurka/php-exec": "~0.1.0" } }
代码使用
$command = new Command('ls'); $result = $command->run(); $result->isSuccess(); $result->getOutput(); $result->getExitCode(); $result->getErrorOutput();
事件
除了基本用法外,您还可以监听截获特定命令事件。所有可能的事件列在下面的示例中
$command = new Command('ls'); $command->on('start', function($pid) { }); $command->on('stdout', function($output) { }); $command->on('stderr', function($error) { }); $command->on('stop', function($exitCode) { }); $command->run();