Recommendation for integrating nodejs with php application

I have an existing application written in PHP (using the Kohana infrastructure), and I want to do a long survey. From some of the things I've read, it seems that a long survey with PHP is not recommended, and using something like nodejs is the best choice. My question is the best way to integrate nodejs (or some other well-suited tool for long polling) with an existing application?

For clarification, my application is basically a browser plugin that you can use to send data to other people's groups. When this data is sent, I want the recipients, if they are online and also have a browser plug-in, immediately receive this data and receive a notification.

+6
php long-polling
source share
2 answers

Perhaps the best way is to let node.js listen on the port and let PHP send messages to that port.

In node.js, you can just open the socket for listening, and in PHP you can use cURL to send messages. Messages can be in JSON format.

If part of node.js receives a message, it can send it, possibly after some processing, directly to the browser with a long poll.

+15
source share

I am creating a small hack that will allow you to do this with ease. It is at a very early stage, but it has enough code for it to work: https://github.com/josebalius/NodePHP

I plan to update readme later today.

-one
source share

All Articles