Package Data | |
---|---|
Maintainer Username: | oldtimeguitarguy |
Maintainer Contact: | karl.hepler@gmail.com (Karl Hepler) |
Package Create Date: | 2016-07-09 |
Package Last Update: | 2016-08-11 |
Language: | PHP |
License: | MIT |
Last Refreshed: | 2024-11-22 03:01:38 |
Package Statistics | |
---|---|
Total Downloads: | 35 |
Monthly Downloads: | 2 |
Daily Downloads: | 0 |
Total Stars: | 0 |
Total Watchers: | 1 |
Total Forks: | 0 |
Total Open Issues: | 0 |
composer require oldtimeguitarguy/laravel-event-subscriber
OldTimeGuitarGuy\LaravelEventSubscriber\EventSubscriberProvider::class,
to the providers array in config/app.php
php artisan vendor:publish
to copy the config file to config/event_subscriber.php
php artisan make:event-subscriber SubscriberName
config/event_subscriber.php
The basic premise of this evolved from here.
I love the idea, but I don't like how you have to define that subscribe
method.
This class eliminates that.
Basically create your event subscriber class just like the documentation says,
but now, if you extend from this class, you never have to write the subscribe
method.
Instead, just prefix all of your event names with on
as public methods.
So you would do something like this:
class MyEventSubscriber extends EventSubscriber
{
public function onUserLogin($event)
{
// do stuff
}
public function onUserLogout($event)
{
// do stuff
}
}
app/Events
directory. (or any class you add to the classmap in the config file)app/Events/
app/Events