For this example we have a scenario, let suppose we have to register/add a new user to our site. when the admin register/add the new user there are multipe events which needs to be handled, in this scenario we have the following two scenario:
- User Need to welcomed through welcome email.
- Admin will be notified that a new user is being registered into your site.
So we are basically creating an event which is resposible to trigger those two events using listeners. These are the main files which we are working in for the events and listerens with queues.
- App
- Events
- Registration
- NewUserRegistrationEvent.php
- Registration
- Jobs
- NewUserRegisteredAdminMailJob.php
- NewUserRegisteredWelcomeMailJob.php
- Listeners
- Registration
- NewUserEmailListener.php
- NewUserSendSlackNotificationListener.php
- Registration
- Mail
- NewUserRegisteredAdminMail.php
- NewUserRegisteredWelcomeMail.php
- Events
Some basic Git commands to run the project | after importing or cloning this project into your local directory:
npm install
composer install
npm run dev
# to run the server
php artisan serve
# open another terminal/cmd tab and run this command to run the queue
php artisan queue:work
Developed by Shakeel Ahmed.