Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

SitePoint PHP Blog:
How to Add Real-Time Notifications to Laravel with Pusher
Jul 28, 2017 @ 14:21:37

The SitePoint PHP blog has posted a new tutorial showing you how you can add real-time notifications to a Laravel application with the help of the Pusher service.

The modern web user expects to be informed of everything that happens within the application. You don’t want to be that one website that doesn’t even have the notifications dropdown found not just in all social media websites, but everywhere else these days, too.

Luckily, with Laravel and Pusher, implementing this functionality is a breeze. The code we’ll write in this tutorial can be found here.

Pusher makes use of Websockets to relay messages back out to waiting clients, sending a push notification (hence the name of the service) rather than waiting for it to poll them for the latest updates. The tutorial starts off by creating a new Laravel installation based on a "blog" example. It then creates the "followers" migration and model and builds out the relationships between it and the user handling. From there they show how to create the routes for following/unfollowing users, the code to perform the action and how to use Laravel's own notifications functionality to integrate with the queue. With that in place they include code to show the current messages (last five) and output the Javascript required to push the messages out to waiting clients.

tagged: tutorial realtime notification laravel pusher websocket

Link: https://www.sitepoint.com/add-real-time-notifications-laravel-pusher/


Trending Topics: