Backend Sharing Data Between Laravel PHP and a Socket.io Server
In a recent project with my colleague Grzegorz Bukat, the server side was dual:
These two servers were directed at a single jQuery front end. The Laravel server generated the views and handled Ajax calls. The Socket.io server dynamically updated the front end when the server state has changed. Both servers used the same MySQL database.
As Socket.io server calls changed server state in a way that would modify the generated views, we had to notify Laravel of these changes.
We decide to use Redis as the communication mechanism between the two servers. As the changes in state were effective during view generation in Laravel, we set Redis keys to signal the Socket.io server state.
Laravel actions fetched the keys from Redis and transferred their values to the views where they were used by the Blade templates.