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

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?

PHP是否有可能与Node.js服务器通信,以模仿完全开发的实时Web应用程序 PHP + Apache + MySQL? p>

我的想法是这样的: p>

两个用户John和Adam正在查看您可以写评论的同一页面 。 p>

  1. John撰写评论并点击提交。 li>
  2. 评论已发布到PHP li>
  3. PHP 将消息保存在数据库中并且Memcached li>
  4. PHP与Node.js通信以更新注释页面 li>
  5. Node.js打开套接字(或使用Socket的其他传输方法) .io)并在浏览器中更新评论页面。 li>
  6. Adam在'实时'中看到页面上添加了新评论 li> ol>

    我想这样做是因为我更容易使用PHP而不是使用node.js处理所有服务器端的东西。 而且我不想将我的整个PHP应用程序世界改为Node.js. 任何好的代码示例? 还是文章? p> div>

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.