API Rest with Laravel 5.6 Passport Authentication — Send Notifications with Queues on Redis (Part 5)

https://medium.com/modulr/api-rest-with-laravel-5-6-175eea5db3e8

We learning how to send Notifications with management to queues using Redis. In this tutorial we will use the Notifications created previously in the previous tutorials.Image for postImage for posthttps://www.vecteezy.com

Install RedisConfig Enviroment Install Redis Driver Run the Queue Worker Install andConfigure supervisor

Step 1 Install Redis

In first step, we install Redis for this I let you two great tutorials for MacOsx and Linux.

Ubuntu 16.04

https://www.digitalocean.com/community/tutorials/how-to-install-and-configure-redis-on-ubuntu-16-04

MacOsx

https://medium.com/@petehouston/install-and-config-redis-on-mac-os-x-via-homebrew-eb8df9a4f298Image for post

Image for post

Step 2 Config Enviroment

In this step we will config our .env file, add redis into QUEUE_DRIVER variable also change the REDIS_ variables, finally config the e-mail service. I recomend Mailtrap to test.

Step 3 Install Redis Driver

We need install Redis driver in to the project, using bellow command, So open your terminal or command prompt and run bellow command:

Step 4 Run the Queue Worker

To test the queues in your local machine need run the queue worker, so run bellow command:

You see in the terminal when the notification is processedImage for postImage for post

Step 5 Install and Configure supervisor

This step is used for production mode in your Linux server.

Install supervisor with the next command:

Enter to folder config.d

Create config file

Into the file write the next code lines

Starting Supervisor

Once the configuration file has been created, you may update the Supervisor configuration and start the processes using the following commands:

Now we are ready to run our example so run bellow command to quick run:

Tests

Now, we can simple test by rest client tools (Postman), So I test it and you can see below screenshots.

In this api you have to set two header as listed below:

SignupImage for postImage for post

When create new account will receive a email with the link to activate accountImage for postImage for post

Thanks for reading! I’m Alfredo Barrón, Feel free to connect with me via Twitter.

Part 1. Passport Authentication Part 2. Confirm account + notifications Part 3. Generate avatar Part 4. Reset Password Part 5. Send Notifications with Queues on Redis — Next up, Localization

Resources

References

FUll CODE

Last updated

Was this helpful?