totten / process-helper
Some quick sugar for working with Symfony Process
Installs: 10 522
Dependents: 6
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 1
Open Issues: 0
Requires
- symfony/process: ^2.0 || ^3.0 || ^4.0 || ^5.0 || ^6.0 || ^7.0
This package is auto-updated.
Last update: 2024-11-27 05:51:40 UTC
README
This is a quick bit of sugar for working with Symfony Process.
use \ProcessHelper\ProcessHelper as PH; $p = PH::runOk(['ls -la @TGT', 'TGT' => '/home/myuser/Documents/Lots of Stuff']); print_r(explode("\n", $p->getOutput()));
Bits of extra behavior:
- Set env var
DEBUG
to display information about any commands as they are executed. (This is loosely similar to using bash'sset -x
.)DEBUG=1
- Show basic summary informationDEBUG=2
- Show full, real-time output
- The
run()
andrunOk()
helpers will execute the command while respecting the DEBUG option. - The
run()
andrunOk()
helpers will automatically cast strings and arrays intoProcess
objects. When constructing theProcess
, variables may be escaped and interpolated. - The
runOk()
helper will assert that the command executed normally. If there's an error, it throws an exception. The resulting exception message will report more details about the failed subcommand.
This doesn't really seem like it should be a standalone project, except that I've found these snippets useful in like 5+ projects...