This free as in freedom component ease up creation of a pipe for processes in php.
Indeed, it is a pseudo pipeline (process collection or process batch) since the php process is single threaded so far.
Currently, there is no plan to bloat the code base with an implementation of STDIN, STDOUT or STDERR. Errors can be handled by the thrown exception. Input is defined by the ExecutableInterface, as well as the output (return value).
The build status of the current master branch is tracked by Travis CI:
It is also available at openhub.net.
Changelog can be found here.
- separate complex operations into simpler
- easy up unit testing for smaller processes
- separate responsibility (data generator/transformer/validator/flow manipulator)
- create process chains you can read in the code (separate integration code from operation code)
- no dependencies (except you want to join the development team)
- no input
- input array
- failing execution
- input generator
- input transformer
- input validator
- data flow manipulator
mkdir -p vendor/net_bazzline/php_component_process_pipe
cd vendor/net_bazzline/php_component_process_pipe
git clone https://github.com/bazzline/php_component_process_pipe
With Packagist
composer require net_bazzline/php_component_process_pipe:dev-master
use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;
try {
$pipe = new Pipe();
$pipe->pipe(
new ProcessOne(),
new ProcessTwo()
);
$output = $pipe->execute($input);
} catch (ExecutableException) {
//handle process exception
} catch (InvalidArgumentException) {
//handle pipe exception
}
use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;
try {
$pipe = new Pipe();
$pipe->pipe(new ProcessOne());
$pipe->pipe(new ProcessTwo());
$output = $pipe->execute($input);
} catch (ExecutableException) {
//handle process exception
} catch (InvalidArgumentException) {
//handle pipe exception
}
use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;
try {
$pipe = new Pipe(
new ProcessOne(),
new ProcessTwo()
);
$output = $pipe->execute($input);
} catch (ExecutableException) {
//handle process exception
} catch (InvalidArgumentException) {
//handle pipe exception
}
use Net\Bazzline\Component\ProcessPipe\ExecutableException;
use Net\Bazzline\Component\ProcessPipe\InvalidArgumentException;
use Net\Bazzline\Component\ProcessPipe\Pipe;
try {
$pipe = new Pipe(
new ProcessOne(),
new ProcessTwo()
);
$pipe->pipe(new ProcessThree());
$pipe->pipe(
new ProcessFour(),
new ProcessFive()
);
$output = $pipe->execute($input);
} catch (ExecutableException) {
//handle process exception
} catch (InvalidArgumentException) {
//handle pipe exception
}
API is available at bazzline.net.
After code changes, please run:
composer check
./vendor/bin/rector process
./vendor/bin/php-cs-fixer fix example
./vendor/bin/php-cs-fixer fix source
./vendor/bin/php-cs-fixer fix test
Star it if you like it :-). Add issues if you need it. Pull patches if you enjoy it. Write a blog entry if you use it. Donate something if you love it :-].