0

I've been learning node.js and socket.io, but I can't see how to use it without transferring everything over to node, which I'm not keen on doing. So my question is, is it at all possible to use node.js alongside PHP?

For example, say I wanted 99.9% of my site to be done in PHP, but I want to use node to display the current number of users online at the top of the page. Is this at all possible, how would I do it?

4
  • print the Socket.io code(javascript) to the page and it must connect to node.js, then starting sending data to keep a track of who is online.. but this would open like 1000connections if 1000 users are online.. if you want only that feature, try caching on php side and some ajax requests Commented Jul 15, 2012 at 10:37
  • See that's what I'm not really understanding here. The only way I know how to connect to node is on an entirely different page (with a different port). I don't understand how to combine it with say my index.php page which connects to apache on port 80. I have to go to a specific url with the port number to view anything I've done in node. Commented Jul 15, 2012 at 10:55
  • socket.io is not related with apache, on php side you just print javascript with which you open a websocket on node.js which in turn listens on a different port Commented Jul 15, 2012 at 10:57
  • Oh, thank you. All the tutorials I've come across have been displaying content on the node server which has made learning how to use it for practical applications problematic for me. This helps a lot. Commented Jul 15, 2012 at 11:00

1 Answer 1

1

I had a similar task for certain extent. Running multiple Node applications with other stuff, no matter static, PHP, Python or something else, on one domain. I consider the best approach is to use Nginx as a web server with appropriate configuration. Here are some details and my configuration example: http://skovalyov.blogspot.com/2012/07/deploy-multiple-node-applications-on.html

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.