task / process
Process plugin for Task
Installs: 2 970
Dependents: 2
Suggesters: 0
Security: 0
Stars: 2
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- symfony/process: ~2.4
- task/plugin: ~1.0
Requires (Dev)
- phpunit/php-code-coverage: ~2.0
- satooshi/php-coveralls: ~0.6
- task/phpspec: ~0.1
- task/phpunit: ~0.1
- task/task: ~0.1
This package is not auto-updated.
Last update: 2025-01-18 16:12:57 UTC
README
Installation
Install via Composer:
... "require-dev": { "task/process": "~0.2" } ...
Usage
Inject into the project container:
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
- The command run:
run('whoami');
array $args = []
- An array of command line arguments:
run('ls', ['-la']);
$cwd = null
- The directory to execute the command in:
run('du', ['-hs'], '/path/to/my/project');
$env
- An array of environment variables:
run('myscript', [], null, ['DEBUG' => 1]);
build($command, array $args = [])
Accepts the same $command
and $args
arguments as run, but returns an instance of Task\Plugin\Process\ProcessBuilder
, which thinly wraps Symfony's ProcessBuilder
, providing an OO interface to confguration a command.