kami / request-processor
Request processor component
Installs: 2 609
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 3
Forks: 0
Open Issues: 0
Requires
- php: ^7.1 || ^8.0
- doctrine/common: ^3.0
- symfony/http-foundation: ^4.4 || ^5.4 || ^6.0
Requires (Dev)
- phpunit/phpunit: ^9.5
This package is auto-updated.
Last update: 2024-11-05 01:54:04 UTC
README
Abstract
Intention of this component is providing more abstract layer
to handling http requests. Utilizing Strategy
pattern, this
RequestProcessor
gives you possibility to dramatically reduce
amount of repeating code in your applications
Installation
composer require kami/request-processor
Usage
Firstly you will need your steps extending RequestProcessor\AbstractStep
<?php use Kami\Component\RequestProcessor\Step\AbstractStep; use Symfony\Component\HttpFoundation\Request; use Kami\Component\RequestProcessor\ArtifactCollection; class MyAwesomeStep extends AbstractStep { public function execute(Request $request) : ArtifactCollection { /** Your execute method */ } public function getRequiredArtifacts() : array { return ['some_artifact']; } }
Build up your strategy
<?php use Kami\Component\RequestProcessor\AbstractStrategy; class MyStrategy extends AbstractStrategy { public static function getSteps() : array { return [ new MyAwesomeStep(), new MyAnotherStep() ]; } }
The one and the only requirement for your strategy
is it should end up with at least two artifacts
data
and status