Welcome to the final chapter of the series, we have touched a lot from the other chapters (chapter 1, chapter 2), and here we end things by talking about
Laravel and the role it plays in our chat application.
I personally think
Laravel is one of the most robust, versatile and well-documented web frameworks. It offers a lot right out of the box, and for the most part, this is a good thing lol. In this project, we use
Laravel purely as a backend API that carries out HTTP request and send back response according.
Sadly we would focus on a fraction of Laravel’s capability, because this is a demo project, and we want to keep things simple. Below are list of things we would be intentionally leaving out not because it not important, but because it saves us time to focus on the functionality which is how to receive information from our Vuejs app and response accordingly.
- HTTP request validation
- Proper response object and status code
- Using the Repository or Service Pattan
Our Laravel Architecture
The diagram shows the flow of data from Vuejs to Laravel and vise vasa. user action results in an HTTP action on the API, a Redis event is published and picked up by the Redis client in on the frontend.
findOrCreatemethod create or return an existing user, and publish a
new_user_joined_eventevent on Redis.
getUsersmethod returns a list of the users
saveMessagemethod creates a new chat message and publishes a
Would love to hear your feedback and thoughts below in the comments
Hope you’ll find this useful!