provision-ops / power-process
A more powerful Process component.
Installs: 14 789
Dependents: 1
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 2
Requires
- php: >=5.5.9|>=7.0.8
- consolidation/robo: ^1
- symfony/process: ^3
Conflicts
- symfony/console: >=4
- symfony/process: >=4
This package is auto-updated.
Last update: 2024-10-29 05:17:01 UTC
README
This library provides an upgraded Symfony Process component.
It gives a more user friendly interface for apps that want to show users what processes are running and what their output is.
This library is used by Provision Yaml Tests and will be used in the Provision CLI project.
Symfony 4
The Symfony Process component has different typehints in the parameters of several APIs in Symfony 4 than Symfony 3 does. This is due to the fact that Symfony 4 requires PHP 7.1.3 or later, which supports a number of typehints not permitted in earlier PHP versions. This difference is minor for most clients, but presents problems for code that subclasses Process, as it is not possible to be compatible with both the Symofny 3 and the Symfony 4 typehints at the same time.
NOTE: A Symfony 4 compatible component will be released at some point.
Big thanks to @g1a and the consolidation team for this block of text, and setting an example of a Process-based component.
See https://github.com/consolidation/site-process/compare/2.x...master as an example on maintaining 2 branches.
Usage
Usage extends the Symfony Process component.
See demo.php for a simple demo:
// Include autoloader include('vendor/autoload.php'); // PowerProcess needs IO. $input = new \Symfony\Component\Console\Input\ArgvInput($argv); $output = new \Symfony\Component\Console\Output\ConsoleOutput(); // Replace Style with your own to change the output style. $io = new ProvisionOps\Tools\Style($input, $output); // Run any command. $command = 'ls -la'; $process = new ProvisionOps\Tools\PowerProcess($command, $io); $process->run();
Then run the file:
php demo.php
You will see the commands running like so:
Another Example
The file `run' is a wrapper for any command.
Try:
./run ping packagist.org -c 5 ./run git status ./run rm -rf /
Simple.
Functionality
This project is being extracted from Provision CLI. It will grow and change rapidly.
Planned functionality:
- Format output for human readability.
- Automatically pipe output to files, with options for destination path. (This is already done in Provision CLI)
- Allow easily silencing output.
- Add hooks to allow other plugins to react to process events.