{"id":22125712,"url":"https://github.com/czim/laravel-processor","last_synced_at":"2025-09-13T22:15:29.181Z","repository":{"id":56960943,"uuid":"43241927","full_name":"czim/laravel-processor","owner":"czim","description":"Pipelined processor framework for Laravel","archived":false,"fork":false,"pushed_at":"2021-04-29T16:36:44.000Z","size":47,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":3,"default_branch":"master","last_synced_at":"2024-04-16T15:12:43.436Z","etag":null,"topics":["laravel","pipeline-processor","processing"],"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/czim.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2015-09-27T10:00:37.000Z","updated_at":"2023-01-26T13:14:56.000Z","dependencies_parsed_at":"2022-08-21T09:20:44.025Z","dependency_job_id":null,"html_url":"https://github.com/czim/laravel-processor","commit_stats":null,"previous_names":[],"tags_count":12,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-processor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-processor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-processor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/czim%2Flaravel-processor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/czim","download_url":"https://codeload.github.com/czim/laravel-processor/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227594885,"owners_count":17791203,"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":["laravel","pipeline-processor","processing"],"created_at":"2024-12-01T16:37:17.879Z","updated_at":"2024-12-01T16:37:18.495Z","avatar_url":"https://github.com/czim.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# Laravel Pipeline Processor\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status](https://travis-ci.org/czim/laravel-processor.svg?branch=master)](https://travis-ci.org/czim/laravel-processor)\n[![Latest Stable Version](http://img.shields.io/packagist/v/czim/laravel-processor.svg)](https://packagist.org/packages/czim/laravel-processor)\n[![SensioLabsInsight](https://insight.sensiolabs.com/projects/7ee4d4b8-9e04-45f0-b5ad-5aeee60e92d6/mini.png)](https://insight.sensiolabs.com/projects/7ee4d4b8-9e04-45f0-b5ad-5aeee60e92d6)\n\n\nFramework for building modular, pipelined data processors. \n\nThe idea behind this is to have a configurable, clean and testable setup for complex data processing.\nIt carries a lot of overhead, of course, so this only makes sense for fairly demanding (background) processing.\n\nUsage example: This was constructed to better handle extensive product and debtor datasheet imports for a particular project.\nThe imported data is converted to a relational database structure spanning many tables.\nUsing pipelined processing, this can be done in discrete, separately testable process step classes that each have their own responsibility.  \n\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require czim/laravel-processor\n```\n\n## Usage\n\nExtend `Czim\\PipelineProcessor` (or `Czim\\AbstractProcessor`) and write implementations for the abstract methods.\n\nProcessing is done by calling the `process()` method on your class.\nThe parameter for this method must be an implementation of `Czim\\DataObject\\Contracts\\DataObjectInterface`\n(see the [czim\\laravel-dataobject](https://github.com/czim/laravel-dataobject) for more information).\n\n```php\n    \n    $processor = new Your\\Processor();\n\n    $data = new Your\\DataObject($someData);\n    \n    $result = $processor-\u003eprocess($data);\n    \n    if ( ! $result-\u003esuccess) {\n        ...\n    }\n```\n\nThe returned result is an instance of `Czim\\Processor\\DataObjects\\ProcessorResult`.\nThis is a DataObject with a boolean `success` property, as well as `warnings` and `errors` MessageBags by default.\n\n\n### Pipeline Processor\n\nA pipeline processor consists of a series of process steps, which are executed in sequence.\n\nA process context is passed into the pipeline and from step to step.\nIt contains the data to be processed, cache, settings and such and its contents may be modified to affect the way subsequent steps behave.\n\nWhen exceptions are thrown, the pipeline ends and the remaining steps are not executed.\n\nTo use it, extend `Czim\\PipelineProcessor` and add the following to your class:\n\n```php\n\n    /**\n     * @return array\n     */\n    protected function processSteps()\n    {\n        // Set a series of process step classnames and return it\n        // these steps must extend Czim\\Processor\\Steps\\AbstractProcessStep\n        // or otherwise implement Czim\\Processor\\Contracts\\ProcessStepInterface\n        return [\n            Your\\ProcessSteps\\ClassNameHere::class,\n            Your\\ProcessSteps\\AnotherClassNameHere::class,\n        ];\n    }\n\n```\n\nFor more configuration options, see [the PipelineProcessor source](https://github.com/czim/laravel-processor/blob/master/src/PipelineProcessor.php).\n\n#### Process Steps\n\nProcess steps can extend `Czim\\Processor\\Steps\\AbstractProcessStep` and implement the `process()` method:\n \n```php\n    protected function process()\n    {\n        // Define your custom processing here.\n        // The data object can be accessed through $this-\u003edata\n        // and the process context through $this-\u003econtext\n    }\n```\n\n#### Process Context\n\nA ProcessContext is an instance that represents the context in which the pipeline steps take place.\nIt stores the data passed into the `process()` method. It can also store settings and a cache.\n \nA `ContextRepositoryTrait` for your own extensions is also  provided,\nin case you want to store repositories with the [czim\\laravel-repository](https://github.com/czim/laravel-repository) package in the context.\n\n\n#### Database Transaction\n\nBy default, the (main) pipeline is executed in a database transaction; it is comitted on succesfully completing all the steps, and rolled back on any exception thrown.\n\nTo run the process without a database transaction, set the following property in your `PipelineProcessor` extension:\n\n```php\n    protected $databaseTransaction = false;\n```\n\n### Simple Processor\n\nIf a pipeline is overkill, you can also use a simpler approach.\n\nExtend `Czim\\AbstractProcessor` and add the following to your class:\n\n```php\n\n    protected function doProcessing()\n    {\n        // Define your custom processing here.\n        // The data object can be accessed through $this-\u003edata\n        \n        // The result data object that will be returned can\n        // be modified through $this-\u003eresult\n    }\n```\n\nFor more configuration options, see [the AbstractProcessor source](https://github.com/czim/laravel-processor/blob/master/src/AbstractProcessor.php).\n\n## To Do\n\n- Make App/Container injectable, remove dependency on laravel's app() function\n\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) for details.\n\n\n## Credits\n\n- [Coen Zimmerman][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more information.\n\n[ico-version]: https://img.shields.io/packagist/v/czim/laravel-processor.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/czim/laravel-processor.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/czim/laravel-processor\n[link-downloads]: https://packagist.org/packages/czim/laravel-processor\n[link-author]: https://github.com/czim\n[link-contributors]: ../../contributors\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczim%2Flaravel-processor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fczim%2Flaravel-processor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fczim%2Flaravel-processor/lists"}