The SitePoint PHP blog has a new tutorial posted from Christopher Pitt showing you how to set up real-time notifications and Follows with Stream in a Laravel application. Stream is a service that helps to take some of the burden out of creating "scalable newsfeeds and activity streams" with just a bit of extra code.
With Laravel, it’s pretty easy to create newsfeed sites, blogs, or even forums where people post content, comment, or even mark some of these posts as favorite. To spice things up, we can make the app more lively by adding notifications for actions performed by other users. In this tutorial, we’ll be relying on a service called Stream to add this functionality to our app.
Using this repository as a starting point how shows how to create a simple blog with some real-time features along with the usual CRUD operations on the blog posts themselves. He starts off by walking through the setup of the project in a Homestead Improved environment. Then it's on to the functionality:
- setting up the user "follow" model and migration
- creating the routes for the follow functionality
- building out the controller and view templates
With that basic structure in place he then brings in the Stream functionality via the get-stream/stream-laravel
package. He shows how to set up an application on the Stream site, configure the connection and add in the functionality to send notifications when posts are created.