If you want to use PHP as the underlying technology, then this will be a tough fight. Read this question on concurrency - how to implement event listener in PHP for more information.
The simplest solution for PHP developers, in my opinion, is to use a hosted real-time service, for example Pusher - for whom I work. This means that you don’t need to worry about installing or maintaining your web infrastructure in real time, and most importantly, you don’t need to worry about your server processing persistent concurrent connections. You use the Pusher JavaScript library, which connects to Pusher from a web browser, maintains a constant connection and receives any updates that push it, and the PESTER REST API to publish data from your PHP application through Pusher to connected clients.
It starts with a Pusher guide on Nettuts + , which has been very popular and a good starting point for anyone using PHP.
If you really want to host your own real-time infrastructure in PHP (don’t say that I didn’t warn you), you can see How to implement PHP with Comet and PHP WebSockets (there is also a github project with recent activity called php-websocket -server ).
source share