Laravel Event System is a flexible and elegant package designed to simplify dynamic event management. It provides a layer on top of Laravel’s native event system, allowing for the registration and removal of events at runtime — perfect for modular applications and plugin-based systems.
Install the package via Composer:
composer require jobmetric/laravel-event-system
Then publish the migration and run it:
php artisan migrate
The default configuration can be published using:
php artisan vendor:publish --tag=event-system-config
return [
"cache_time" => env("EVENT_SYSTEM_CACHE_TIME", 60),
"cache_key" => env("EVENT_SYSTEM_CACHE_KEY", "event_system_cache"),
"tables" => [
'event' => 'events',
],
];
You can dynamically register or remove events at runtime using the helper functions:
addEventSystem('user.created', App\Events\UserCreated::class, App\Listeners\SendWelcomeEmail::class, 'Triggered when a new user registers');
removeEventSystem('user.created');
The package also emits its own events:
Event | Description |
---|---|
EventSystemStoreEvent |
Dispatched after an event has been registered |
EventSystemDeletingEvent |
Dispatched before an event is removed |
EventSystemDeletedEvent |
Dispatched after an event has been removed |
Thank you for considering contributing to the Laravel Event System! The contribution guide can be found in the CONTRIBUTING.md.
The MIT License (MIT). Please see License File for more information.