任务/流程

Task 的流程插件

v0.3.1 2014-05-04 13:21 UTC

This package is not auto-updated.

Last update: 2024-09-28 14:46:50 UTC


README

Build Status Coverage Status

安装

通过 Composer 安装

...
    "require-dev": {
        "task/process": "~0.2"
    }
...

使用

注入到项目容器中

use Task\Plugin\ProcessPlugin;

$project->inject(function ($container) {
    $container['ps'] = new ProcessPlugin;
});

$project->addTask('whoami', ['ps', function ($ps) {
    $ps->run('whoami')->pipe($this->getOutput());
}]);

API

run($command, array $args = [], $cwd = null, array $env = [], OutputInterface $output = null)

$command - 执行的命令

run('whoami');

array $args = [] - 命令行参数数组

run('ls', ['-la']);

$cwd = null - 执行命令的目录

run('du', ['-hs'], '/path/to/my/project');

$env - 环境变量数组

run('myscript', [], null, ['DEBUG' => 1]);
build($command, array $args = [])

接受与 run 相同的 $command$args 参数,但返回一个 Task\Plugin\Process\ProcessBuilder 实例,它薄包装了 Symfony 的 ProcessBuilder,提供了一个面向对象的接口来配置命令。