使用meteor.js与php服务器端

时间:2022-03-23 15:37:07

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.js进行实时更新(我希望增强但不能更改我的程序,例如当用户添加注释使其实时更新时)。问题是meteor.js使用node.js(所以javascript作为服务器端代码)。我使用LAMP堆栈,是否可以让PHP从mysql将数据提供给meteor.js。

4 个解决方案

#1


10  

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不仅仅是一个“交互式web应用程序”构建器或javascript框架。我们的想法是只使用一种编程语言(除了用于标记的HTML / CSS)来完成所有工作。基本上它创建了一个“远程服务器”(在客户端浏览器中),它可以将数据推送到用户系统并同时向用户系统发布各种API。通过这些API /连接传递的数据具有特定的结构,必须始终遵守。

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构建的,这使得在没有这个后端的情况下运行它很困难(如果不是不可能的话)。当然你可以尝试使用PHP模仿后端,但这会浪费时间。阅读你的问题,你最好使用像jQuery或Prototype这样的javascript框架。与Meteor不同,您需要自己进行AJAX调用(POST和CallBack),但实际上您可以自己决定使用哪个后端(包括PHP / MySQL)。

If you want to do this anyway you need to check the Meteor & NodeJS source code to see what the minimum requirements are to make Meteor run under PHP. The PHP stack has to interpret the commands Meteor sends and receivers, but this won't be an easy task.

如果你想要这样做,你需要检查Meteor和NodeJS源代码,看看使Meteor在PHP下运行的最低要求是什么。 PHP堆栈必须解释Meteor发送和接收器的命令,但这不是一件容易的事。

#2


3  

You can use comet (or reverse ajax) for realtime updates.

您可以使用comet(或reverse ajax)进行实时更新。

#3


1  

Trying to marry node.js with PHP doesn't sound like a worthwhile path to go down. If someone insisted on using a system like Meteor.js, yet with a PHP back-end, it would make more sense to look at AngularJS which is mainly the client side.

试图将node.js与PHP结合起来听起来并不是一条值得走下去的道路。如果有人坚持使用像Meteor.js这样的系统,但是使用PHP后端,那么查看主要是客户端的AngularJS会更有意义。

Of course, that is different technology stack. If someone really insisted on the blending, one could consider using server side sockets to interact with PHP Web services; and/or use mongodb and/or mysql-node to interact with the same databases.

当然,这是不同的技术堆栈。如果有人真的坚持混合,可以考虑使用服务器端套接字与PHP Web服务进行交互;和/或使用mongodb和/或mysql-node与相同的数据库进行交互。

#4


1  

I released a meteorite package that interacts with a Wordpress site that has the Wordpress JSON API. A quick fix. For now.

我发布了一个陨石包,它与一个拥有Wordpress JSON API的Wordpress网站进行交互。快速解决。目前。

Comes with a backend call that will return the raw data, or a publication that stores the posts using their id's instead of a randomly generated mongoid. And some basic templates to get you started including a Session variable that keeps track of the currently selected post.

附带一个将返回原始数据的后端调用,或者使用其id而不是随机生成的mongoid存储帖子的发布。还有一些基本的模板可以让你开始包括一个跟踪当前所选帖子的Session变量。

I'm working on it a lot more and will eventually have a version that directly makes mysql calls from node so you won't need php or Wordpress; just the ability to access the mysql database (which can be remote, with the appropriate configuration, or on the same machine).

我正在研究它,并且最终将有一个版本直接从节点进行mysql调用,所以你不需要php或Wordpress;只是能够访问mysql数据库(可以是远程,具有适当的配置,或在同一台机器上)。

#1


10  

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不仅仅是一个“交互式web应用程序”构建器或javascript框架。我们的想法是只使用一种编程语言(除了用于标记的HTML / CSS)来完成所有工作。基本上它创建了一个“远程服务器”(在客户端浏览器中),它可以将数据推送到用户系统并同时向用户系统发布各种API。通过这些API /连接传递的数据具有特定的结构,必须始终遵守。

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构建的,这使得在没有这个后端的情况下运行它很困难(如果不是不可能的话)。当然你可以尝试使用PHP模仿后端,但这会浪费时间。阅读你的问题,你最好使用像jQuery或Prototype这样的javascript框架。与Meteor不同,您需要自己进行AJAX调用(POST和CallBack),但实际上您可以自己决定使用哪个后端(包括PHP / MySQL)。

If you want to do this anyway you need to check the Meteor & NodeJS source code to see what the minimum requirements are to make Meteor run under PHP. The PHP stack has to interpret the commands Meteor sends and receivers, but this won't be an easy task.

如果你想要这样做,你需要检查Meteor和NodeJS源代码,看看使Meteor在PHP下运行的最低要求是什么。 PHP堆栈必须解释Meteor发送和接收器的命令,但这不是一件容易的事。

#2


3  

You can use comet (or reverse ajax) for realtime updates.

您可以使用comet(或reverse ajax)进行实时更新。

#3


1  

Trying to marry node.js with PHP doesn't sound like a worthwhile path to go down. If someone insisted on using a system like Meteor.js, yet with a PHP back-end, it would make more sense to look at AngularJS which is mainly the client side.

试图将node.js与PHP结合起来听起来并不是一条值得走下去的道路。如果有人坚持使用像Meteor.js这样的系统,但是使用PHP后端,那么查看主要是客户端的AngularJS会更有意义。

Of course, that is different technology stack. If someone really insisted on the blending, one could consider using server side sockets to interact with PHP Web services; and/or use mongodb and/or mysql-node to interact with the same databases.

当然,这是不同的技术堆栈。如果有人真的坚持混合,可以考虑使用服务器端套接字与PHP Web服务进行交互;和/或使用mongodb和/或mysql-node与相同的数据库进行交互。

#4


1  

I released a meteorite package that interacts with a Wordpress site that has the Wordpress JSON API. A quick fix. For now.

我发布了一个陨石包,它与一个拥有Wordpress JSON API的Wordpress网站进行交互。快速解决。目前。

Comes with a backend call that will return the raw data, or a publication that stores the posts using their id's instead of a randomly generated mongoid. And some basic templates to get you started including a Session variable that keeps track of the currently selected post.

附带一个将返回原始数据的后端调用,或者使用其id而不是随机生成的mongoid存储帖子的发布。还有一些基本的模板可以让你开始包括一个跟踪当前所选帖子的Session变量。

I'm working on it a lot more and will eventually have a version that directly makes mysql calls from node so you won't need php or Wordpress; just the ability to access the mysql database (which can be remote, with the appropriate configuration, or on the same machine).

我正在研究它,并且最终将有一个版本直接从节点进行mysql调用,所以你不需要php或Wordpress;只是能够访问mysql数据库(可以是远程,具有适当的配置,或在同一台机器上)。