{"id":20538663,"url":"https://github.com/karlhepler/laravel-event-subscriber","last_synced_at":"2026-04-21T13:33:25.529Z","repository":{"id":57030874,"uuid":"62964281","full_name":"karlhepler/laravel-event-subscriber","owner":"karlhepler","description":"This makes your event subscribers a little cleaner","archived":false,"fork":false,"pushed_at":"2016-08-11T18:03:50.000Z","size":6,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"master","last_synced_at":"2025-02-17T09:39:09.491Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/karlhepler.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2016-07-09T18:49:52.000Z","updated_at":"2020-07-27T11:36:35.000Z","dependencies_parsed_at":"2022-08-23T18:50:37.164Z","dependency_job_id":null,"html_url":"https://github.com/karlhepler/laravel-event-subscriber","commit_stats":null,"previous_names":[],"tags_count":5,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlhepler%2Flaravel-event-subscriber","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlhepler%2Flaravel-event-subscriber/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlhepler%2Flaravel-event-subscriber/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/karlhepler%2Flaravel-event-subscriber/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/karlhepler","download_url":"https://codeload.github.com/karlhepler/laravel-event-subscriber/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242144497,"owners_count":20078966,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-11-16T00:47:22.464Z","updated_at":"2026-04-21T13:33:20.483Z","avatar_url":"https://github.com/karlhepler.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"Laravel Event Subscriber\n=========================\n\nInstallation\n-------------\n\n1. `composer require oldtimeguitarguy/laravel-event-subscriber`\n2. Add `OldTimeGuitarGuy\\LaravelEventSubscriber\\EventSubscriberProvider::class,` to the providers array in `config/app.php`\n3. Run `php artisan vendor:publish` to copy the config file to `config/event_subscriber.php`\n\n\n\n\n\nUsage\n------\n\n1. Create subscribers with `php artisan make:event-subscriber SubscriberName`\n2. Add custom event classes in `config/event_subscriber.php`\n\n\n\n\n\nDescription\n------------\n\nThe basic premise of this evolved from [here](https://laravel.com/docs/5.2/events#event-subscribers).\n\nI love the idea, but I don't like how you have to define that `subscribe` method.\n\nThis class eliminates that.\n\nBasically create your event subscriber class just like the documentation says,\nbut now, if you extend from this class, you never have to write the `subscribe` method.\n\nInstead, just prefix all of your event names with `on` as public methods.\n\nSo you would do something like this:\n\n```php\nclass MyEventSubscriber extends EventSubscriber\n{\n    public function onUserLogin($event)\n    {\n        // do stuff\n    }\n\n    public function onUserLogout($event)\n    {\n        // do stuff\n    }\n}\n```\n\nThat's it. There are a couple of caveats:\n------------------------------------------\n\n1. It looks for the events in Laravel's `app/Events` directory. (or any class you add to the classmap in the config file)\n2. You can have a maximum of **one** subdirectory under `app/Events/`\n3. Be careful about name collisions, even if the event classes exist in different subdirectories under `app/Events`\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlhepler%2Flaravel-event-subscriber","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkarlhepler%2Flaravel-event-subscriber","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkarlhepler%2Flaravel-event-subscriber/lists"}