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.comarrow-up-right

Install Redisarrow-up-rightConfig Enviromentarrow-up-right Install Redis Driverarrow-up-right Run the Queue Workerarrow-up-right Install andConfigure supervisorarrow-up-right

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-04arrow-up-right

MacOsx

https://medium.com/@petehouston/install-and-config-redis-on-mac-os-x-via-homebrew-eb8df9a4f298arrow-up-rightImage 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 Mailtraparrow-up-right 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 Twitterarrow-up-right.

Part 1. Passport Authenticationarrow-up-right Part 2. Confirm account + notificationsarrow-up-right Part 3. Generate avatararrow-up-right Part 4. Reset Passwordarrow-up-right Part 5. Send Notifications with Queues on Redis — Next up, Localization

Resources

References

FUll CODE

Last updated