https://github.com/mkgor/pipeliner
Pipeliner is a simple pipeline implementation, which allows you to decompose any big action in your application into small and replacable parts,
https://github.com/mkgor/pipeliner
bag chain composer-package middleware pattern php-library php7 pipeliner
Last synced: 11 months ago
JSON representation
Pipeliner is a simple pipeline implementation, which allows you to decompose any big action in your application into small and replacable parts,
- Host: GitHub
- URL: https://github.com/mkgor/pipeliner
- Owner: mkgor
- License: mit
- Created: 2019-10-24T19:39:40.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2020-04-24T08:58:07.000Z (about 6 years ago)
- Last Synced: 2025-04-26T15:02:21.201Z (about 1 year ago)
- Topics: bag, chain, composer-package, middleware, pattern, php-library, php7, pipeliner
- Language: PHP
- Homepage: https://pixaye.github.io/pipeliner/
- Size: 42 KB
- Stars: 2
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Pipeliner





Pipeliner is a simple pipeline implementation, which allows you to decompose any big action in your application into small and replacable parts, so you can change some behavior in this action in runtime. It makes your application simple to test, easy to find bugs/identify problematic areas and makes it really flexible.
To start using pipeliner, just run the composer command
```bash
composer require mkgor/pipeliner
```
# Usage
```php
$pipeline = new Pipeliner\Pipeline();
$pipeline->pipe(new ExampleMiddleware());
->pipe(new SecondExampleMiddleware());
->exec();
```
Let`s see what does middleware class contain
```php
pipe(new ExampleMiddleware())
->pipe(new SecondExampleMiddleware())
->pipe(new ClosureMiddleware('SomeActionName', function(){
return 'I am clousure';
}, 'FourthMiddleware'))
->pipe(new FourthMiddleware())
->exec();
```
Every middleware class have private $bag variable, which contains instance of BagInterface (RuntimeBag at the time, but you can make your own, for example you can contain data in database or in file).
It contains all results from previous middlewares and have four methods which allows you to get/set that data.
```php
$this->bag->put('NameOfMiddleware', $data);
$this->bag->get('NameOfMiddleware');
$this->bag->getLast();
$this->bag->getAll();
```
You can set your own bag, just create one which implements BagInterface and that`s it!
```php
$pipeliner = new Pipeliner\Pipeline();
$pipeliner->setPipelineBag(new YourOwnBagClass());
...
```