在PHP服务器端使用meteor.js

在PHP服务器端使用meteor.js

问题描述:

我已经开发了一个应用程序,希望使用meteor.js进行实时更新(我想增强但不更改程序,例如,当用户添加评论时,使其进行实时更新).问题是meteor.js使用node.js(因此javascript作为服务器端代码).我使用LAMP堆栈,是否有可能使PHP从mysql向meteor.js中馈送数据.

I've developed an application that I would like to use meteor.js for real time updates (I want to enhance but not change my program, for example when a user adds a comments make it update in real-time ) . Problem is meteor.js uses node.js (so javascript as server-side code). I use LAMP stack, Is it possible to get PHP to feed data into meteor.js from mysql.

Meteor不仅仅是一个交互式Web应用程序"构建器或javascript框架.这个想法是只有一种编程语言(HTML/CSS除外)来完成所有工作.基本上,它创建了一个远程服务器"(在客户端浏览器中),可以将数据推送到该服务器,同时将各种API发布到用户系统.通过这些API的/连接传递的数据具有必须始终遵守的特定结构.

Meteor is more than just an 'interactive webapplication'-builder or javascript framework. The idea is to have only one programming language (besides HTML/CSS for markup) to do all the work. Basically it creates a 'remote server' (in the clients browser) it can push data to and at the same time it publishes various API's to the users system. The data passed through these API's / connections has a specific structure which has to be adhered at all time.

Meteor是围绕NodeJS构建的,这使得(如果不是不可能的话)很难在没有此后端的情况下运行它.当然,您可以尝试使用PHP模仿后端,但这会浪费时间.阅读您的问题,您最好使用jQuery或Prototype之类的javascript框架.与Meteor不同,您将需要自己进行AJAX调用(POST和CallBack),但实际上可以决定要使用哪个后端(包括PHP/MySQL).

Meteor is built around NodeJS, which makes it hard (if not impossible) to run it without this backend. Sure you can try to mimic the backend using PHP, but it would be a waste of time. Reading your question you'll be better of using a javascript framework like jQuery or Prototype. Unlike Meteor you will need to do the AJAX calls (POST & CallBack) yourself, but you can actually decide which backend you want to use yourself (including PHP / MySQL).

如果仍然要执行此操作,则需要检查Meteor& NodeJS源代码,以了解使Meteor在PHP下运行的最低要求. PHP堆栈必须解释Meteor发送和接收的命令,但这并不是一件容易的事.