3 changed files with 80 additions and 84 deletions
-
4.env.example
-
21LICENSE
-
139README.md
@ -0,0 +1,21 @@ |
|||
MIT License |
|||
|
|||
Copyright (c) 2020 Nafies Luthfi |
|||
|
|||
Permission is hereby granted, free of charge, to any person obtaining a copy |
|||
of this software and associated documentation files (the "Software"), to deal |
|||
in the Software without restriction, including without limitation the rights |
|||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|||
copies of the Software, and to permit persons to whom the Software is |
|||
furnished to do so, subject to the following conditions: |
|||
|
|||
The above copyright notice and this permission notice shall be included in all |
|||
copies or substantial portions of the Software. |
|||
|
|||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|||
SOFTWARE. |
|||
@ -1,85 +1,60 @@ |
|||
<p align="center"><img src="https://res.cloudinary.com/dtfbvvkyp/image/upload/v1566331377/laravel-logolockup-cmyk-red.svg" width="400"></p> |
|||
|
|||
<p align="center"> |
|||
<a href="https://travis-ci.org/laravel/framework"><img src="https://travis-ci.org/laravel/framework.svg" alt="Build Status"></a> |
|||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/d/total.svg" alt="Total Downloads"></a> |
|||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/v/stable.svg" alt="Latest Stable Version"></a> |
|||
<a href="https://packagist.org/packages/laravel/framework"><img src="https://poser.pugx.org/laravel/framework/license.svg" alt="License"></a> |
|||
</p> |
|||
|
|||
## About Laravel |
|||
|
|||
Laravel is a web application framework with expressive, elegant syntax. We believe development must be an enjoyable and creative experience to be truly fulfilling. Laravel takes the pain out of development by easing common tasks used in many web projects, such as: |
|||
|
|||
- [Simple, fast routing engine](https://laravel.com/docs/routing). |
|||
- [Powerful dependency injection container](https://laravel.com/docs/container). |
|||
- Multiple back-ends for [session](https://laravel.com/docs/session) and [cache](https://laravel.com/docs/cache) storage. |
|||
- Expressive, intuitive [database ORM](https://laravel.com/docs/eloquent). |
|||
- Database agnostic [schema migrations](https://laravel.com/docs/migrations). |
|||
- [Robust background job processing](https://laravel.com/docs/queues). |
|||
- [Real-time event broadcasting](https://laravel.com/docs/broadcasting). |
|||
|
|||
Laravel is accessible, powerful, and provides tools required for large, robust applications. |
|||
|
|||
## Learning Laravel |
|||
|
|||
Laravel has the most extensive and thorough [documentation](https://laravel.com/docs) and video tutorial library of all modern web application frameworks, making it a breeze to get started with the framework. |
|||
|
|||
If you don't feel like reading, [Laracasts](https://laracasts.com) can help. Laracasts contains over 1500 video tutorials on a range of topics including Laravel, modern PHP, unit testing, and JavaScript. Boost your skills by digging into our comprehensive video library. |
|||
|
|||
## Laravel Sponsors |
|||
|
|||
We would like to extend our thanks to the following sponsors for funding Laravel development. If you are interested in becoming a sponsor, please visit the Laravel [Patreon page](https://patreon.com/taylorotwell). |
|||
|
|||
### Premium Partners |
|||
|
|||
- **[Vehikl](https://vehikl.com/)** |
|||
- **[Tighten Co.](https://tighten.co)** |
|||
- **[Kirschbaum Development Group](https://kirschbaumdevelopment.com)** |
|||
- **[64 Robots](https://64robots.com)** |
|||
- **[Cubet Techno Labs](https://cubettech.com)** |
|||
- **[Cyber-Duck](https://cyber-duck.co.uk)** |
|||
- **[Many](https://www.many.co.uk)** |
|||
- **[Webdock, Fast VPS Hosting](https://www.webdock.io/en)** |
|||
- **[DevSquad](https://devsquad.com)** |
|||
|
|||
### Community Sponsors |
|||
|
|||
<a href="https://op.gg"><img src="http://opgg-static.akamaized.net/icon/t.rectangle.png" width="150"></a> |
|||
|
|||
- [UserInsights](https://userinsights.com) |
|||
- [Fragrantica](https://www.fragrantica.com) |
|||
- [SOFTonSOFA](https://softonsofa.com/) |
|||
- [User10](https://user10.com) |
|||
- [Soumettre.fr](https://soumettre.fr/) |
|||
- [CodeBrisk](https://codebrisk.com) |
|||
- [1Forge](https://1forge.com) |
|||
- [TECPRESSO](https://tecpresso.co.jp/) |
|||
- [Runtime Converter](http://runtimeconverter.com/) |
|||
- [WebL'Agence](https://weblagence.com/) |
|||
- [Invoice Ninja](https://www.invoiceninja.com) |
|||
- [iMi digital](https://www.imi-digital.de/) |
|||
- [Earthlink](https://www.earthlink.ro/) |
|||
- [Steadfast Collective](https://steadfastcollective.com/) |
|||
- [We Are The Robots Inc.](https://watr.mx/) |
|||
- [Understand.io](https://www.understand.io/) |
|||
- [Abdel Elrafa](https://abdelelrafa.com) |
|||
- [Hyper Host](https://hyper.host) |
|||
- [Appoly](https://www.appoly.co.uk) |
|||
- [云软科技](http://www.yunruan.ltd/) |
|||
|
|||
## Contributing |
|||
|
|||
Thank you for considering contributing to the Laravel framework! The contribution guide can be found in the [Laravel documentation](https://laravel.com/docs/contributions). |
|||
|
|||
## Code of Conduct |
|||
|
|||
In order to ensure that the Laravel community is welcoming to all, please review and abide by the [Code of Conduct](https://laravel.com/docs/contributions#code-of-conduct). |
|||
|
|||
## Security Vulnerabilities |
|||
|
|||
If you discover a security vulnerability within Laravel, please send an e-mail to Taylor Otwell via [taylor@laravel.com](mailto:taylor@laravel.com). All security vulnerabilities will be promptly addressed. |
|||
# Laravel Queue Notifer Example |
|||
|
|||
This is a sample project for implementing realtime feature for laravel using these packages: |
|||
|
|||
1. Laravel websockets (https://github.com/beyondcode/laravel-websockets) |
|||
2. Laravel Echo (https://github.com/laravel/echo) |
|||
3. Noty JS (https://ned.im/noty) |
|||
|
|||
## Features |
|||
|
|||
This project is just an example impelemntation, so we will have: |
|||
|
|||
1. A basic job run for 5 seconds in the background, then notify all users after done (without refreshing the browser). |
|||
2. 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 |
|||
|
|||
1. PHP ^7.2 (And meet the [laravel 7.x server requirements](https://laravel.com/docs/7.x/#server-requirements)). |
|||
2. MySQL or MariaDB or Sqlite database. |
|||
|
|||
### How to Install |
|||
|
|||
1. Clone the repo: `$ git clone https://github.com/nafiesl/laravel-queue-notifier-example.git` |
|||
2. `$ cd laravel-queue-notifier-example` |
|||
3. `$ composer install` |
|||
4. `$ cp .env.example .env` |
|||
5. `$ php artisan key:generate` |
|||
6. Create a MySQL/MariaDB/Sqlite database for this project |
|||
7. Set the database credential on `.env` file |
|||
8. `$ php artisan migrate` |
|||
9. `$ php artisan serve` |
|||
10. Open a new terminal tab `$ php artisan queue:work` |
|||
11. Open a new terminal tab (again) `$ php artisan websockets:serve` |
|||
12. The project is ready to use. |
|||
|
|||
## How to Use |
|||
|
|||
1. Open the web page via browser `http://127.0.0.1:8000` (the given link on How to Install step #9) |
|||
2. Register as a new user: `John` (we will be redirected to the `/home` route) |
|||
3. Open a new browser with incognito/private mode, go to `http://127.0.0.1:8000` |
|||
4. Register as a new different user: `David` (we will be redirected to the `/home` route as well) |
|||
5. 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. |
|||
6. When David hits the **Run a long job** button, same behavior on point #5 happen for David. |
|||
7. 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. |
|||
|
|||
## License |
|||
|
|||
The Laravel framework is open-sourced software licensed under the [MIT license](https://opensource.org/licenses/MIT). |
|||
This sample project is a free and open-source under [MIT license](LICENSE). |
|||
Write
Preview
Loading…
Cancel
Save
Reference in new issue