在 php 服务器端使用meteor.js [英] Using meteor.js with php server side

查看:23
本文介绍了在 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 和回调),但实际上您可以决定要使用哪个后端(包括 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 发送和接收的命令,但这不是一件容易的事.

这篇关于在 php 服务器端使用meteor.js的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆