duanposhi3641
2014-01-28 14:42 阅读 38

PHP与运行除Apache之外的Node.js(Socket.io)进行通信

Is it possible that PHP to communicate with Node.js server in order to mimic real-time web apps developed completely in PHP+Apache+MySQL?

My thinking is this:

Two users, John and Adam, are viewing the same page where you can write comments.

  1. John writes a comment and hits submit.
  2. The comment is POSTed to PHP
  3. PHP saves the message in a database and Memcached
  4. PHP communicates with Node.js to update the comments page
  5. Node.js opens a socket (or other transport method with Socket.io) and updates the comments page in the browser.
  6. Adam sees a new comment added on the page in 'real-time'

I want to do this because it's much easier for me to work with PHP instead of handling all server-side stuff with node.js. And I don't want to change my whole world of PHP app to Node.js. Any good code example? or article?

  • 点赞
  • 写回答
  • 关注问题
  • 收藏
  • 复制链接分享

1条回答 默认 最新

  • 已采纳
    dongyin2885 dongyin2885 2014-01-28 14:59

    I would recommend dnode-php to accomplish this. Dnode is an asynchronous rpc system for node.js that lets you call remote functions and dnode-php is the php implementation.

    点赞 评论 复制链接分享

相关推荐