kleytonsantos/pipeline-bundle
Composer 安装命令:
composer require kleytonsantos/pipeline-bundle
包简介
A symfony package to handle a pipeline structure
README 文档
README
PipelineBundle is a Symfony component that allows you to create and execute data processing pipelines in a flexible and dynamic way.
📦 Instalação
Installing the bundle with Composer, run the following command:
composer require kleytonsantos/pipeline-bundle
// config/bundles.php return [ KleytonSantos\Pipeline\PipelineBundle::class => ['all' => true], ];
🚀 Uso Básico
1️⃣ Create a Pipeline Configuration
Adding a pipeline configuration to config/packages/pipeline.yaml:
# config/packages/pipeline.yaml pipeline: pipelines: my_pipeline: - my_pipe1 - my_pipe2
2️⃣ Custom Pipes
<?php declare(strict_types=1); namespace App\Pipe; class TrimPipe implements PipelineInterface { public function handle(mixed $passable, \Closure $next): mixed { return $next(trim($passable)); } }
3️⃣ Execute the Pipeline
3.1 using through method to manually pass the pipes
$result = $pipeline ->send($passable) ->through([ App\Pipe\CustomPipe1::class, App\Pipe\CustomPipe2::class, ]) ->thenReturn();
3.2 using withConfig method to use config from pipeline.yaml
$result = $pipeline ->send($passable) ->withConfig('my_pipeline') ->thenReturn();
📄 Methods Summary
| Methods | Description |
|---|---|
send(mixed $passable): static |
Defines the data to be processed in the pipeline. |
withConfig(string $configName): static |
Use config from pipeline.yaml. |
through(array $pipes): static |
Pass the pipes manually. |
then(Closure $destination): mixed |
Process the pipeline and execute a final function. |
thenReturn(): mixed |
Process the pipeline and return the final result. |
统计信息
- 总下载量: 6
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-03-09