1. Go to this page and download the library: Download syberisle/pipeline library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
use SyberIsle\Pipeline\Pipeline;
use SyberIsle\Pipeline\Processor;
use SyberIsle\Pipeline\Stage;
class TimesTwoStage implements Stage
{
public function process($payload)
{
return $payload * 2;
}
}
class AddOneStage implements Stage
{
public function process($payload)
{
return $payload + 1;
}
}
$pipeline = (new Pipeline\Simple)
->pipe(new TimesTwoStage)
->pipe(new AddOneStage);
// Returns 21
(new Processor\FingersCrossed())->process($pipeline, 10);
$processApiRequest = (new Pipeline)
->pipe(new ExecuteHttpRequest) // 2
->pipe(new ParseJsonResponse); // 3
$pipeline = (new Pipeline)
->pipe(new ConvertToPsr7Request) // 1
->pipe($processApiRequest) // (2,3)
->pipe(new ConvertToResponseDto); // 4
(new Processor\FingersCrossed())->process($pipeline, new DeleteBlogPost($postId));
use SyberIsle\Pipeline\Pipeline\SimpleBuilder;
// Prepare the builder
$pipelineBuilder = (new SimpleBuilder)
->add(new LogicalStage)
->add(new AnotherStage)
->add(new LastStage);
// Build the pipeline
$pipeline = $pipelineBuilder->build();
$pipeline = (new Pipeline)->pipe(function () {
throw new LogicException();
});
try {
(new Processor\FingersCrossed())->process($pipeline, $payload);
} catch(LogicException $e) {
// Handle the exception.
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.