0

Lately, I have been doing a lot of research (of course googling :P) on building real-time application (like chat application). So far I have come across Elephant.io, Socket.io and Ratchet. And some of the terms I stumbled upon were web-sockets, bi-directional communication etc..

I am building an auction site where it involves countdown timer. I am trying to achieve something like when one user bids, the timer gets updated in all the client's browser without page refresh (something like server broadcasting the change of event to all other connected users).

The problem is, I am building the application with PHP (Pyro-cms). The server, where it will be uploaded is Apache-based server and does not support node.js. One of the most common stuff I notice was most of the real-time applications were utilizing node.js.

Is it possible to build real-time application using PHP , Socket.io and javascript only? or may be with angular.js?

I really cannot use the server that support node.js so have to completely rely on apache server. I even dont know if it is possible. If there is any resources, reference or tutorial, it will be very helpful.

Nirmalz Thapaz
  • 925
  • 4
  • 13
  • 28
  • Yes, PHP does support sockets: http://php.net/manual/en/book.sockets.php And there are a lot of libraries abstracting those lower level functions into something easy and safe to use. – Sergiu Paraschiv Jul 10 '15 at 12:13
  • If you want a websocket server in php, you'd write a php script that you'd have to boot up via CLI which would then act as a server and do exactly the same job as node.js, except it would be written by you, untested, and probably with tons of bugs for start. This means you are not doing yourself any favors, and all the logic dictates that it's better to use Node.js for websocket side of your app. Now, why you can't use node together with Apache - that's something I don't know but when you want to drive a car, you must fill it with gas or it won't go. You want to go without gas. Won't work – N.B. Jul 10 '15 at 12:19
  • Possible duplicates: http://stackoverflow.com/questions/6398887/using-php-with-socket-io, http://stackoverflow.com/questions/6229472/socket-io-from-php-source – cmbuckley Jul 10 '15 at 12:20
  • You know that socket.io is node.js library, don't you? – Estus Flask Jul 10 '15 at 12:30
  • why can't you use Ratchet? – charlietfl Jul 10 '15 at 12:37
  • If your server can not use node.js, then you can not use Socket.io. Look for a PHP based WebSocket server. Although, if you don't have enough control over your server to use node.js, it's possible that you can't run a WebSocket server either. – Ghedipunk Jul 10 '15 at 16:00
  • And, from the way you worded your question, it sounds like you don't have a basic understanding of WebSockets yet. It does not run on Apache. It *might* run alongside Apache, but the web server itself really shouldn't matter. WebSockets is not a request/response system, it's a full duplex, always running server process that is completely independent of any web requests. It just happens to play nice with port 80 for the sake of firewalls, and happens to be well supported in every major browser. – Ghedipunk Jul 10 '15 at 16:03
  • @charlietfl could not find enough resources to learn. Although it has a nice tutorial explaining but it seems very incomplete. I have done 'Hello World' tutorial and its all based on running server through CLI and testing the application through client's browser console. I am still not able to grasp the concept and how would I use it in my actual application. – Nirmalz Thapaz Jul 11 '15 at 06:04

0 Answers0