chrisjohnson00/controller-callback-bundle
preCallback for feature flag checks).postCallback logic (e.g., logging deprecation warnings).EventDispatcher).EventDispatcher or middleware is more maintainable.#[BeforeRoute]).nelmio/cors-bundle (for CORS), or custom middleware.middleware or route filters.To Executives: "This bundle lets us add lightweight ‘before/after’ logic to existing Symfony 2 controllers without rewriting them—think of it as ‘sticky notes’ for your routes. Use cases include A/B testing, analytics, or deprecation warnings. It’s a low-risk way to modernize legacy systems while keeping costs down (MIT license, minimal overhead). Trade-off: Limited to Symfony 2, but we can phase it out during our next major upgrade."
To Engineering: *"This is a Symfony 2-specific way to inject pre/post controller hooks via route config (no code changes). Example:
# config/routes.yml
my_route:
path: /example
defaults: { _controller: AppController::action }
callbacks:
pre: [App\Callback\AuthCheck, 'validate']
post: [App\Callback\Logger, 'logResponse']
Pros:
EventDispatcher or middleware. For Laravel, use native middleware."*To Developers: *"Need to add a quick pre-flight check or post-action logging to a controller? This bundle lets you define it in YAML:
callbacks:
pre: [App\Service\RateLimiter, 'check']
post: [App\Service\Metrics, 'record']
Controller::handle() with your callbacks.EventDispatcher when ready."*How can I help you explore Laravel packages today?