timobakx/api-events-bundle
A PHP bundle for structured API event handling. Define and dispatch events around API interactions, then use listeners to react to lifecycle changes and keep application behavior organized, decoupled, and easy to extend with event-driven hooks.
This is a Symfony bundle, not a Laravel package — there is no service provider, no facade, and no package auto-discovery. Read the release notes with that lens: v1.1.1 is a compatibility release (Symfony 7, PHPUnit 10), so nothing you already have wired up should break, but the floor on your dependency versions moves up.
Minimal steps:
composer require timobakx/api-events-bundle — check the resolved symfony/* constraints; v1.1.1 is the first release that will happily resolve against Symfony 7.config/bundles.php (Symfony) — TimoBakx\ApiEventsBundle\ApiEventsBundle::class => ['all' => true]. If you are pulling this into a Laravel app, you must register it manually in a service provider and boot the container bindings yourself; nothing is auto-wired for you.vendor/timobakx/api-events-bundle/src/ — specifically the event classes and the subscriber/listener that dispatches them. That pair tells you the entire contract faster than the README.config/packages/api_events.* in the bundle's DependencyInjection/ folder to see which knobs actually exist before inventing your own.Listener-first integration. The bundle's value is the event objects it dispatches. Write a subscriber that implements EventSubscriberInterface, map the bundle's event constants to methods, and set priorities deliberately — response-mutating listeners should run late, logging/telemetry listeners early.
Version-gated wiring. If you support both Symfony 6.4 LTS and 7.x across environments, pin ^1.1.1 only where PHP 8.2+ is guaranteed; keep ^1.1.0 on older branches. Don't try to make one lockfile serve both.
Adapter pattern for Laravel. Since Laravel already ships Symfony's EventDispatcher under the hood, the cheapest integration is to bind the bundle's event classes into Laravel's dispatcher and listen with standard Event::listen() calls. Treat the bundle as a source of event value objects rather than as a framework integration.
Test with attributes, not annotations. PHPUnit 10 support means the package's own suite moved to attributes. Mirror that in your tests: #[DataProvider('...')] with a public static provider method, #[Test] where relevant. If your app is still on PHPUnit 9, you can consume the bundle fine — the constraint only affects the dev dependencies of the bundle itself.
Config-driven enablement. Wrap listener registration in a config flag so the events can be silenced in local/CLI contexts where the API lifecycle doesn't apply.
config/api-events.php to publish, no php artisan vendor:publish, no facade. Anything you want configurable, you wrap yourself.composer why-not timobakx/api-events-bundle 1.1.1 rather than guessing.@expectedException, setUp(): void signatures. If you copy test patterns out of the bundle's repo into a PHPUnit 9 project, they will fail.bin/console debug:event-dispatcher (and debug:event-dispatcher <event.name>) shows whether your listener is actually registered and at what priority. Nine times out of ten a "listener never fires" bug is a missing bundle registration or a listener registered on the wrong event constant.kernel.event_subscriber remain the sanctioned extension mechanism.compare/v1.1.0...v1.1.1 is a single PR — low risk, no deprecations introduced, but it also means no new features. Don't plan work around capabilities you assumed were added.How can I help you explore Laravel packages today?