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
Dispatcher Bundle

Dispatcher Bundle Laravel Package

acassan/dispatcher-bundle

acassan/dispatcher-bundle provides a small dispatcher bundle for Laravel/PHP projects, packaging dispatcher-related wiring and configuration so you can register and use a dispatcher in your application with minimal setup.

View on GitHub
Deep Wiki
Context7

At a glance

Frequently asked questions about Dispatcher Bundle
How does this bundle differ from Laravel’s native `Event::dispatch()`?
This bundle adds a centralized dispatcher layer that supports middleware, dynamic handler resolution, and potential async workflows—features not natively available in Laravel’s event system. It’s designed for projects needing structured event routing, prioritization, or cross-service communication beyond basic event dispatching.
Does this work with Laravel’s queue system for async dispatching?
The bundle is designed to integrate with Laravel’s queue system, allowing you to dispatch events asynchronously. However, it doesn’t replace the queue system—it works alongside it. You’ll need to configure the dispatcher to use queues for specific handlers or events, similar to how you’d use `Event::later()` or queue listeners.
What Laravel versions and PHP versions does this bundle support?
The bundle explicitly supports Laravel 8.x and 9.x, with PHP 8.0+ as the minimum requirement. Check the package’s `composer.json` for the latest version constraints, as support for Laravel 10 may vary. Always verify compatibility with your project’s dependencies before installation.
Can I use this bundle alongside Laravel’s native event system?
Yes, the bundle is designed to coexist with Laravel’s native event system. You can use it for specific workflows while keeping other events dispatched via `Event::dispatch()`. However, avoid mixing the two for the same event type to prevent ambiguity in handler resolution.
How do I register handlers or middleware for the dispatcher?
Handlers are registered via the bundle’s configuration or service provider bindings. Middleware can be stacked in the dispatcher pipeline using the `DispatcherInterface` methods. The bundle provides a fluent API for defining routes, handlers, and middleware chains—similar to Laravel’s route model binding but for events.
Is there built-in support for event prioritization or conditional dispatching?
Yes, the bundle supports prioritized dispatching by allowing you to define handler order and conditions (e.g., based on event payload or context). This is useful for scenarios like multi-tenant applications where certain handlers should only run for specific tenants or roles.
What’s the performance impact compared to native `Event::dispatch()`?
The bundle introduces minimal overhead for basic dispatching, but additional features like middleware or async support may add latency. Benchmark your use case by comparing `Dispatcher::dispatch()` with `Event::dispatch()` in a controlled environment. For most projects, the difference is negligible unless you’re dispatching thousands of events per second.
How do I test this bundle in a Laravel application?
Test the dispatcher by mocking its `dispatch()` method and verifying handler execution. Use Laravel’s testing tools to assert that events are dispatched correctly and that middleware pipelines behave as expected. For async workflows, test queue jobs separately to ensure they’re processed by the dispatcher’s configured handlers.
Are there alternatives to this bundle for centralized event dispatching?
For Laravel, alternatives include custom event service classes, packages like `spatie/laravel-event-scheduler`, or rolling your own dispatcher using Laravel’s service container. If you need async support, consider `laravel-horizon` for queue management or `symfony/messenger` for advanced messaging. This bundle is unique in its focus on middleware and dynamic routing.
What’s the rollback plan if this bundle causes issues in production?
If the bundle introduces instability, revert to Laravel’s native event system by removing the bundle’s service provider from `config/app.php` and replacing `Dispatcher::dispatch()` calls with `Event::dispatch()`. Ensure you have a backup of your event listeners and middleware configurations to restore them quickly.
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.
codifyo/ts-generator-bundle
andydefer/laravel-cluster
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor