You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
|
|
5 years ago | |
|---|---|---|
| app | 5 years ago | |
| bootstrap | 5 years ago | |
| config | 5 years ago | |
| database | 5 years ago | |
| public | 5 years ago | |
| resources | 5 years ago | |
| routes | 5 years ago | |
| storage | 5 years ago | |
| tests | 5 years ago | |
| .editorconfig | 5 years ago | |
| .env.example | 5 years ago | |
| .gitattributes | 5 years ago | |
| .gitignore | 5 years ago | |
| .styleci.yml | 5 years ago | |
| LICENSE | 5 years ago | |
| README.md | 5 years ago | |
| artisan | 5 years ago | |
| composer.json | 5 years ago | |
| composer.lock | 5 years ago | |
| package-lock.json | 5 years ago | |
| package.json | 5 years ago | |
| phpunit.xml | 5 years ago | |
| server.php | 5 years ago | |
| webpack.mix.js | 5 years ago | |
README.md
Laravel Queue Notifer Example
This is a sample project for implementing realtime feature for laravel using these packages:
- Laravel websockets (https://github.com/beyondcode/laravel-websockets)
- Laravel Echo (https://github.com/laravel/echo)
- Noty JS (https://ned.im/noty/v2)
Features
This project is just an example impelemntation, so we will have:
- A basic job run for 5 seconds in the background, then notify all users after done (without refreshing the browser).
- A basic job run for 5 seconds in the background, then notify only the current user (privately, also without refreshing the browser).
Getting Started
Server Requirements
- PHP ^7.2 (And meet the laravel 7.x server requirements).
- MySQL or MariaDB or Sqlite database.
How to Install
- Clone the repo:
$ git clone https://github.com/nafiesl/laravel-queue-notifier-example.git $ cd laravel-queue-notifier-example$ composer install$ cp .env.example .env$ php artisan key:generate- Create a MySQL/MariaDB/Sqlite database for this project
- Set the database credential on
.envfile $ php artisan migrate$ php artisan serve- Open a new terminal tab
$ php artisan queue:work - Open a new terminal tab (again)
$ php artisan websockets:serve - The project is ready to use.
How to Use
- Open the web page via browser
http://127.0.0.1:8000(the given link on How to Install step #9) - Register as a new user:
John(we will be redirected to the/homeroute) - Open a new browser with incognito/private mode, go to
http://127.0.0.1:8000 - Register as a new different user:
David(we will be redirected to the/homeroute as well) - When John hits the Run a long job button
- John will be redireted back to home
- John will get a notifier message on the bottom right
Please wait, your request is processing.... - Don't refresh the page, just wait...
- After 5 seconds, both John and David will get a notifier message
Long run job done after 5 seconds - John and David get the notifier, because this is a public channel for all users.
- When David hits the Run a long job button, the same behavior on point #5 happens for David.
- When David hits the Run a long private job button
- David will be redirected back to home
- Davil will get a notifier message on the bottom right
Please wait, your request is processing.... - Don't refresh the page, just wait...
- After 5 seconds, both David will get a notifier message
Long run private job (for '...') done after 5 seconds - John will not get the notifier, because this is a private channel for David.
- When John hits the Run a long private job button, the same behavior on point #7 happens for John.
License
This sample project is a free and open-source under MIT license.