PHP application + WebSocket based notifications over Socket.IO

There isn't an easy way to communicate between node and apache/php. So you're either going to have to write all of your functionality again in node (connecting to mysql databases and such) or create an API to call from Node and pass to sockets.

However you could use a jquery plugin like Jquery graceful websockets and this php class to get your own websockets functionality with jquery and php, rather than using sockets.io.


This tutorial on using PHP and Socket.IO answers the main part of your question.

socket.io isn't your only options. Have a look at the realtime web tech guide. By the looks of it the best PHP-based solution right now is Ratchet. This needs to run as a separate process so you're still going to have the cross-process communication problem.

The common cross process communication problem is to use messages queues. The problem then comes in when you want your PHP app running on Apache to be informed of events from the realtime web technology. You're probably going to have to do that via a web call, even if it's a call from the realtime web tech process to the apache server.

Another option is to offload the realtime communication to a hosted service like Pusher who I work for.

This recent question is also relevant and has some useful links: Is native PHP support for Web Sockets available?


Elephant.IO supports PHP with Socket.IO so take a look at it!