ivol/exec-wrapper

允许从命令行执行应用程序。

v1.0.0-RC1 2016-05-25 18:46 UTC

This package is auto-updated.

Last update: 2024-08-29 04:14:33 UTC


README

Latest Stable Version Build Status Code Coverage Scrutinizer Quality Score Total Downloads

执行包装器是一个扩展,以面向对象的方式实现外部应用程序的执行。还允许在执行前后添加监听器。

安装

将 exec-wrapper 添加到您的 Composer 项目中

composer require ivol/exec-wrapper

用法

非常简单

<php>
// Autoload here
use ivol/ExecutionWrapper;

$wrapper = new ExecutionWrapper();
$result = $wrapper->execute('echo %s', ['123']);
if ($result->getReturnCode() == 0) {
    echo('Success');
} else {
    echo('Failure');
}
echo($result->getOutput());
</php>

如果您想使用事件系统,则应配置事件分发器

...
$dispatcher = $wrapper->getEventDispatcher();
$dispatcher->addSubscriber(...);
$dispatcher->addListener(...);
...

有关事件分发器的更多信息,请参阅 事件分发器组件

有关更多示例,请参阅 ExecutionWrapperIntegrationTest

配置

您可以通过传递配置数组到 ExecWrapper 来配置 args 和命令转义的行为。

有关配置选项名称,请参阅 ExecWrapperConfiguration

许可证

exec-wrapper 在 MIT 许可证下发布。