Currently I have a website which I wrote on PHP via the Laravel framework. I have wrote a live chat using nodeJS with Socket.IO and Express and now what I want to do is to integrate it inside my already written Laravel website. The problem is the chat must be in the main page, which is currently rendered by the views of Laravel. Currently I am on a shared hosting.
The question: What are your best suggestions for such integration? I know that the LAMP stack comes ready in most shared domains but I have completely no idea how I am to get PHP(Laravel) and my nodeJS chat to work together.
Things I have tried:
- Elephant.IO - Didn't have any big success with it yet...
the solution is simple (but finding ANYTHING about it on the internet was not). You just need to include your socket.io JS file in the HTML view of PHP, then the socket.io JS files makes a connection to your node.JS server. This works all fine on localhost. However, if someone else tries to log into your chat from outside, they will experience a "Forbidden crossdomain request" error, which is because you have probably followed some "guide" like me and your socket.io connection in the CLIENT is like that:
instead of
The PHP client code is:
The server-side node.JS code does not need any tweaks, forget everything about Redis or in PHP (Elephant.IO, AJAX random injects, forget about any hacks). It simply works as a magic.