illuminate/events
Illuminate Events is Laravel’s event dispatcher component, providing a simple way to register listeners and subscribers, dispatch events, and build decoupled, extensible application workflows with synchronous or queued handling.
The illuminate/events package provides a simple event dispatcher implementation, leveraging Laravel’s contract-based architecture. To start:
composer.json requirements), as this package targets the latest framework version.laravel/framework), it can be used standalone in any PHP project that supports PSR-11 containers.use Illuminate\Events\Dispatcher;
use Illuminate\Container\Container;
$events = new Dispatcher(Container::getInstance());
$events->listen(UserRegistered::class, function ($event) {
logger()->info('New user registered: ' . $event->user->email);
});
Check tests/ for usage patterns if official docs are minimal.
Dispatcher with a Container to inject dependencies into listeners:
$container = new Container;
$container->singleton(LoggerInterface::class, MonologLogger::class);
$events = new Dispatcher($container);
$events->listen(OrderShipped::class, ShipNotificationListener::class); // Listener resolved from container
$events->listen('*.shipped', function ($event) { /* unified shipping logging */ });
Dispatcher with Mockery or PHPUnit doubles to assert event dispatching occurs without triggering real side effects.Dispatcher, otherwise listener instantiation may fail silently.listen() or manually via service providers.laravel/octane, custom queue workers).illuminate/container: Even standalone, the container dependency means you’ll need to resolve dependencies recursively. Prefer a DI container like PHP-DI and wrap it in an Illuminate\Container\Container adapter.Dispatcher::setLogCalls(true) to log all event dispatches via Laravel’s logger for tracing — invaluable when listener chains are complex.How can I help you explore Laravel packages today?