blackmesa/chainofresponsibility-bundle
FrameworkBundle or HttpKernel. Complements Symfony’s event system or filters for extensibility.composer require + config. Minimal boilerplate for basic use cases.symfony/framework-bundle (v5.4+) and symfony/dependency-injection. No external PHP extensions required.void execute()).ChainException strategy in config.HttpKernel filters or EventDispatcher for similar use cases.Stopwatch or custom metrics.KernelEvents::REQUEST to a CoR chain for auth/validation.call_user_func_array) to YAML.dump-autowiring to identify dependencies for handlers.symfony/dependency-injection compatibility.ChainOfResponsibility\HandlerInterface (or extend AbstractHandler).@ChainPriority) if supported.composer require mesa-black/chainofresponsibility-bundle
Add to config/bundles.php:
Mesa\Black\ChainOfResponsibilityBundle\ChainOfResponsibilityBundle::class => ['all' => true],
config/packages/chain_of_responsibility.yaml:
mesa_black_chain_of_responsibility:
chains:
request_validation:
handlers:
- Mesa\App\Handler\AuthHandler
- Mesa\App\Handler\ValidationHandler
stop_on_failure: true
namespace Mesa\App\Handler;
use Mesa\Black\ChainOfResponsibility\HandlerInterface;
class AuthHandler implements HandlerInterface {
public function handle($request, callable $next) {
if (!$request->isAuthenticated()) {
throw new \RuntimeException('Unauthorized');
}
return $next($request);
}
}
$chain = $this->container->get('mesa_black_chain_of_responsibility.chain.request_validation');
$result = $chain->process($request);
Config component).ErrorHandler.composer.json as a private package for stability.| Failure Type | Impact | Mitigation |
|---|---|---|
| Handler Exception | Chain stops (if stop_on_failure). |
Use try-catch in handlers or global error handling. |
| Circular Dependencies | Infinite loop. | Validate config with a dependency graph tool. |
| Misconfigured Chain | Silent failures. | Add health checks (e.g., ping a dummy chain). |
| Resource Leaks | Memory bloat (e.g., unclosed DB). | Enforce handler contracts (e.g., finally blocks). |
How can I help you explore Laravel packages today?