Examples of Events & listeners (16)

Short information about events & listeners

The main usage of the Events and Listeners pattern is that you can specify in the code that some event has just happened, and then there are Listener classes that automatically catch the Event and perform some action. You can attach one or multiple listener classes to one event.
In this way, you separate the code from the Controller to another layer, also helping the future developers who may want to expand functionality by listening to the same event.
An example may be the event "Registered User", which would have a couple of Listeners: one would send an email to the admin, another one would create some database records for that user, etc.
Read more in the official Laravel docs.

Repository: koel/koel (Github)
★ 13870 Created: Dec 2015 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Listeners/DownloadArtistImage.php
- app/Providers/EventServiceProvider.php
Repository: firefly-iii/firefly-iii (Github)
★ 8598 Created: Jun 2014 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Handlers/Events/StoredAccountEventHandler.php
- app/Events/StoredAccount.php
- app/Providers/EventServiceProvider.php
- app/Factory/AccountFactory.php
Repository: akaunting/akaunting (Github)
★ 5417 Created: Sep 2017 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Providers/Event.php
- app/Events/Document/DocumentViewed.php
- app/Listeners/Document/MarkDocumentViewed.php
- app/Http/Controllers/Portal/Invoices.php
Repository: laravelio/laravel.io (Github)
★ 2186 Created: May 2016 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Events/ArticleWasApproved.php
- app/Providers/EventServiceProvider.php
- app/Listeners/SendArticleApprovedNotification.php
Repository: Bottelet/DaybydayCRM (Github)
★ 2016 Created: Jul 2016 Updated: Jul 2022 Laravel version: 7
Files in the example:
- app/Listeners/ProjectActionNotify.php
- app/Providers/EventServiceProvider.php
- app/Events/ProjectAction.php
- app/Http/Controllers/ProjectsController.php
Repository: HDInnovations/UNIT3D-Community-Edition (Github)
★ 1548 Created: Dec 2017 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Listeners/FailedLoginListener.php
Repository: range-of-motion/budget (Github)
★ 781 Created: Jul 2017 Updated: Jul 2022 Laravel version: 8
Files in the example:
- app/Events/ImportCreated.php
- app/Models/Import.php
Repository: nasirkhan/laravel-starter (Github)
★ 618 Created: Oct 2017 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- /app/Listeners/Backend/UserCreated/UserCreatedProfileCreate.php
- app/Http/Controllers/Backend/UserController.php
Repository: nafiesl/free-pmo (Github)
★ 362 Created: Nov 2017 Updated: Jul 2022 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Events/Projects/Created.php
- app/Listeners/Projects/LogProjectCreationActivity.php
Repository: agorakit/agorakit (Github)
★ 358 Created: May 2016 Updated: Jun 2022 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Http/Controllers/CommentController.php
- app/Listeners/NotifyMentionedUsers.php
Repository: tighten/novapackages (Github)
★ 305 Created: Feb 2020 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Http/Controllers/App/PackageController.php
- app/Events/PackageCreated.php
- app/Listeners/SendNewPackageNotification.php
Repository: jcergolj/laravellte (Github)
★ 202 Created: Jan 2020 Updated: Jul 2022 Laravel version: 8
Files in the example:
- app/Events/ProfileImageUploaded.php
- app/Listeners/ResizeImage.php
- app/Providers/EventServiceProvider.php
- app/Http/Livewire/Profile/UpdateImage.php
Repository: LaraBug/larabug-app (Github)
★ 190 Created: Apr 2021 Updated: Jul 2022 Laravel version: 8
Files in the example:
- app/Listeners/UpdateLoginData.php
- app/Providers/EventServiceProvider.php
Repository: academico-sis/academico (Github)
★ 126 Created: Dec 2018 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Events/CourseUpdated.php
- app/Listeners/UpdateCourseEvents.php
- app/Providers/EventServiceProvider.php
- app/Models/ExternalCourse.php
Repository: OpenLitterMap/openlittermap-web (Github)
★ 82 Created: Aug 2020 Updated: Aug 2022 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Events/Photo/IncrementPhotoMonth.php
- app/Listeners/UpdateTags/ResetCompileString.php
- app/Listeners/UpdateTags/DecrementCity.php
Repository: JustinByrne/Mealing (Github)
★ 73 Created: Oct 2020 Updated: May 2022 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Events/UserVerified.php
- app/Listeners/SendNewUserNotification.php

Additional resources on events & listeners: