Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Controller Callback Bundle Laravel Package

chrisjohnson00/controller-callback-bundle

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Middleware/Interceptors for Legacy Systems: Enables adding pre/post logic to controllers without modifying existing code, aligning with clean architecture principles.
  • A/B Testing or Feature Flags: Quickly route traffic to alternate controller logic (e.g., preCallback for feature flag checks).
  • Analytics/Logging: Inject instrumentation (e.g., timing, user tracking) without bloating controllers.
  • Deprecation Paths: Gradually phase out old controllers by wrapping them in postCallback logic (e.g., logging deprecation warnings).
  • Build vs. Buy: Justifies buying this over custom middleware if:
    • Team lacks Symfony expertise.
    • Need a lightweight, configurable solution (vs. building from scratch).
    • Symfony 2 is a legacy constraint (though Symfony 6+ has native alternatives like EventDispatcher).
  • Roadmap for Migration: Use as a stopgap during Symfony 2 → 3/4/5 upgrades, replacing callbacks with modern middleware later.

When to Consider This Package

  • Avoid if:
    • Using Symfony 3+: Native EventDispatcher or middleware is more maintainable.
    • Need complex logic: Callbacks are limited to simple function calls (no dependency injection or async tasks).
    • Performance-critical: Adds minimal overhead but isn’t optimized for high-throughput routes.
    • Modern stack: Prefer Laravel’s middleware or PHP 8 attributes (#[BeforeRoute]).
  • Look elsewhere for:

How to Pitch It (Stakeholders)

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:

  • No controller refactoring.
  • Works with existing Symfony 2 apps.
  • Config-driven (no PHP changes). Cons:
  • Archived (last commit 2015)—vetted for our Symfony 2.8 use case.
  • Not for complex logic (e.g., async tasks). Alternatives: If we’re upgrading, use Symfony’s 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']
  • How it works: Under the hood, it wraps Controller::handle() with your callbacks.
  • Limitations:
    • No DI in callbacks (manually resolve services).
    • Symfony 2 only (won’t work with 3+).
  • Migration path: Replace with Symfony’s EventDispatcher when ready."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
codeflextech/permission-manager
karnoweb/livewire-datepicker
sayedenam/sayed-dashboard
milito/query-filter
apiboxsym/user-bundle
apiboxsym/health-check-bundle
jayeshmepani/jpl-moshier-ephemeris-php
elnasnato/laraliveui
labrodev/rest-sdk
sampaui/sampaui
babelqueue/php-sdk
facebook/capi-param-builder-php
babelqueue/symfony
hamzi/corewatch
minionfactory/raw-hydrator
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver