{"id":23219110,"url":"https://github.com/b2pweb/bdf-pipeline","last_synced_at":"2025-09-02T21:36:16.996Z","repository":{"id":62490846,"uuid":"123280559","full_name":"b2pweb/bdf-pipeline","owner":"b2pweb","description":null,"archived":false,"fork":false,"pushed_at":"2018-06-01T15:02:38.000Z","size":24,"stargazers_count":1,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-03-13T06:48:33.904Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/b2pweb.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2018-02-28T12:15:21.000Z","updated_at":"2018-06-01T15:02:39.000Z","dependencies_parsed_at":"2022-11-02T09:31:32.181Z","dependency_job_id":null,"html_url":"https://github.com/b2pweb/bdf-pipeline","commit_stats":null,"previous_names":[],"tags_count":3,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-pipeline","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-pipeline/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-pipeline/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/b2pweb%2Fbdf-pipeline/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/b2pweb","download_url":"https://codeload.github.com/b2pweb/bdf-pipeline/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247353682,"owners_count":20925325,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-18T21:19:18.805Z","updated_at":"2025-04-05T14:42:42.634Z","avatar_url":"https://github.com/b2pweb.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# B2PWeb Pipeline\n\nA PHP Pipeline pattern.\n\n[![Build Status](https://travis-ci.org/b2pweb/bdf-pipeline.svg?branch=master)](https://travis-ci.org/b2pweb/bdf-pipeline)\n[![Scrutinizer Code Quality](https://scrutinizer-ci.com/g/b2pweb/bdf-pipeline/badges/quality-score.png?b=master)](https://scrutinizer-ci.com/g/b2pweb/bdf-pipeline/?branch=master)\n[![Packagist Version](https://img.shields.io/packagist/v/b2pweb/bdf-pipeline.svg)](https://packagist.org/packages/b2pweb/bdf-pipeline)\n[![Total Downloads](https://img.shields.io/packagist/dt/b2pweb/bdf-pipeline.svg)](https://packagist.org/packages/b2pweb/bdf-pipeline)\n\n## Install via composer\n```bash\n$ composer require b2pweb/bdf-pipeline\n```\n\n## Usage Instructions\n\nA basic and classic use of pipeline with a pipe processor.\n\n```PHP\nuse Bdf\\Pipeline\\Pipeline;\nuse Bdf\\Pipeline\\CallableFactory\\LinkedCallableFactory;\n\n$pipeline = new Pipeline(new LinkedCallableFactory());\n$pipeline-\u003epipe(function($value) {\n    return $value + 2;\n});\n\n// Returns 12\n$pipeline-\u003esend(10);\n```\n\nThe pipeline lib comes with an advanced processor (used by default).\n\n```PHP\nuse Bdf\\Pipeline\\Pipeline;\nuse Bdf\\Pipeline\\CallableFactory\\StackCallableFactory;\n\n$pipeline = new Pipeline(new StackCallableFactory());\n$pipeline-\u003epipe(function($next, $foo, $bar) {\n    // Do something\n    ...\n    \n    $result = $next($foo, $bar);\n    \n    // Do something else\n    ...\n    \n    return $result;\n});\n$pipeline-\u003eoutlet(function($foo, $bar) {\n    return \"${foo}.${bar}\";\n});\n// Manage multiple parameters\necho $pipeline-\u003esend('foo', 'bar'); // Print foo.bar\n```\n\n## Ok, So ? \n\nYou can use this package as a classic pipe, but it was designed to be easily extended:\n\n```PHP\n$pipeline-\u003epipe(new LogCommand());\n$pipeline-\u003eoutlet(new CreateUserHandler());\n\n...\n\n$pipeline-\u003eprepend(new TransactionnalCommand());\n$pipeline-\u003esend(new CreateUserCommand());\n```\n\n```PHP\nclass TransactionnalCommand\n{\n    public function __invoke($next, $command)\n    {\n        try {\n            $result = $next($command);\n            \n            // Commit and return the result\n            ...\n            return $result;\n        } catch (\\Throwable $exception) {\n            // Rollback and propagate exception\n            throw $exception;\n        }\n    }\n}\n```\n\nThe pipeline is reusable:\n\n```PHP\n$pipeline = new Pipeline();\n$pipeline-\u003epipe(new Double());\n\n$new = clone $pipeline;\n\n$new-\u003epipe(new Double());\n\necho $pipeline-\u003esend(2); // 4\necho $new-\u003esend(2); // 8\n```\n\n## License\n\nDistributed under the terms of the MIT license.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-pipeline","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fb2pweb%2Fbdf-pipeline","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fb2pweb%2Fbdf-pipeline/lists"}