gnugat/query-bus-bundle
Symfony bundle that integrates gnugat/query-bus, making it easy to register query handlers and dispatch queries through the container. It wires the query bus into Symfony services for cleaner CQRS-style read models.
composer require gnugat/quer-bus) and let Laravel auto-discover the service provider. If auto-discovery is disabled, register Gnugat\QueryBus\QueryBusServiceProvider manually in config/app.php.php artisan vendor:publish --tag=query_bus_config if available). The two container entries to note are:
gnugat_query_bus.query_bus – the query bus servicegnugat_query_bus.query_matcher – the service that maps a query to its handlergnugat_query_bus.query_bus, then inject the query bus into a controller and call $bus->dispatch(new MyQuery(...)). Start with a single query/handler pair to confirm the tag-to-handler wiring works before adding more.__invoke method. Tag the handler with gnugat_query_bus.query_bus in a service provider using $this->app->tag([MyHandler::class], 'gnugat_query_bus.query_bus').gnugat_query_bus.query_bus) or, if the package exposes an interface, type-hint that interface and bind it in a provider.public function show(QueryBus $bus, int $id): JsonResponse
{
return response()->json($bus->dispatch(new GetUserQuery($id)));
}
gnugat_query_bus.query_matcher service is the extension point for custom query-to-handler resolution. Replace or decorate it in a service provider if you need conventions (e.g. FooQuery → FooHandler) instead of explicit tagging.app()->tagged('gnugat_query_bus.query_bus').gnugat_query_bus.query_bus, not query_bus or a class name. A typo silently leaves the handler unregistered, and dispatching will fail at runtime.$this->app->tag($handlers, 'gnugat_query_bus.query_bus').gnugat_query_bus.query_matcher and add guard clauses or custom resolution logic early.php artisan optimize:clear and re-cache (php artisan optimize) in production. Stale compiled containers are a common cause of "handler not found" errors.php artisan tinker and app()->tagged('gnugat_query_bus.query_bus') to list registered handlers. app()->make('gnugat_query_bus.query_bus') confirms the bus resolves. For deeper inspection, bind a decorator that logs every dispatch.gnugat/quer-bus, so expect semver stability going forward. The container IDs and tag name are now public contracts—avoid relying on internal classes until they are documented.#[Tag] attributes. Prefer explicit provider registration over guessing.How can I help you explore Laravel packages today?