Examples of Events & listeners (13)

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)
★ 12683 Created: Dec 2015 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Listeners/DownloadArtistImage.php
- app/Providers/EventServiceProvider.php
Repository: akaunting/akaunting (Github)
★ 4174 Created: Sep 2017 Updated: Jul 2021 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)
★ 1889 Created: May 2016 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Events/ArticleWasApproved.php
- app/Providers/EventServiceProvider.php
- app/Listeners/SendArticleApprovedNotification.php
Repository: Bottelet/DaybydayCRM (Github)
★ 1748 Created: Jul 2016 Updated: Jun 2021 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)
★ 1366 Created: Dec 2017 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Listeners/FailedLoginListener.php
Repository: nasirkhan/laravel-starter (Github)
★ 364 Created: Oct 2017 Updated: Jun 2021 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- /app/Listeners/Backend/UserCreated/UserCreatedProfileCreate.php
- app/Http/Controllers/Backend/UserController.php
Repository: agorakit/agorakit (Github)
★ 332 Created: May 2016 Updated: Jun 2021 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Http/Controllers/CommentController.php
- app/Listeners/NotifyMentionedUsers.php
Repository: tighten/novapackages (Github)
★ 202 Created: Feb 2020 Updated: Jul 2021 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: LaraBug/larabug-app (Github)
★ 125 Created: Apr 2021 Updated: Jun 2021 Laravel version: 8
Files in the example:
- app/Listeners/UpdateLoginData.php
- app/Providers/EventServiceProvider.php
Repository: jcergolj/laravellte (Github)
★ 122 Created: Jan 2020 Updated: Jun 2021 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: OpenLitterMap/openlittermap-web (Github)
★ 54 Created: Aug 2020 Updated: Jul 2021 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: academico-sis/academico (Github)
★ 45 Created: Dec 2018 Updated: Aug 2021 Laravel version: 8
Files in the example:
- app/Events/CourseUpdated.php
- app/Listeners/UpdateCourseEvents.php
- app/Providers/EventServiceProvider.php
- app/Models/ExternalCourse.php
Repository: JustinByrne/Mealing (Github)
★ 42 Created: Oct 2020 Updated: Jul 2021 Laravel version: 8
Files in the example:
- app/Providers/EventServiceProvider.php
- app/Events/UserVerified.php
- app/Listeners/SendNewUserNotification.php

Additional resources on events & listeners: