問題描述
我開發了一個應用程序,我想使用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的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!