7

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.

5
  • 1
    Meteor.js is a solid system/framework built by Node.js/MongoDB/Javascript. It can't be a stand-alone service for your exiting programs. That means if you want the adding comment looks like realtime, the comment page must be built by Meteor.js. Commented Aug 3, 2012 at 15:44
  • You should probably choose an answer now Commented Mar 12, 2013 at 13:39
  • I'm looking for the same thing. We have a PHP application and need real time for the front end. Later we will likely migrate the whole application to meteor. I think meteor is setup to handle this. There's github.com/We-Inspire/WIConnect-node for Laravel (a php application) so I know people are trying it. Commented Nov 3, 2014 at 3:29
  • Here is a demo of WIConnect DDP with Laravel (PHP framework) but it's used with angular for client. Hopefully I'll get a chance to make a meteor example soon. github.com/We-Inspire/WIConnect-Demos Commented Dec 22, 2014 at 19:13
  • @LenXu: that is not correct. Meteor can serve data via a REST API (see nimble:restivus) or via DDP. If the client uses a DDP library such as Asteroid, they can get live updates from Meteor, regardless of the server of the app (PHP or whatever). Commented Jun 13, 2015 at 4:58

4 Answers 4

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 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).

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.

Sign up to request clarification or add additional context in comments.

2 Comments

This answer isn't really valid anymore. Meteor is setup to use DDP, which according to the docs CAN work in any language. meteor.com/blog/2012/03/21/introducing-ddp
While you're absolutely right about DDP allowing you to connect to a client and push data though, the answer itself is still valid. Using PHP you need to mimic the backend and push data though an API / protocol (DDP). The most difficult to create is a stack that reacts on (for example) database changes and pushes these to the connected clients. As for DDP, it's actually ment for different clients (e.g. an iOS-application) to connect the meteor.js-server (meteor.com/ddp).
3

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

Comments

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.

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.

2 Comments

There is no mixing of node.js with PHP in the question. He wants real-time client-side updates with an existing PHP application. In that light, the comet answer is close.
I didn't mention node.js, but the question mentions PHP, node.js, and meteor, AND asks how it is possible to mix them. The comet answer is fine, though comet and ajax are worse-is-better solutions that are resource hogs, especially for mobile devices.
1

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

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.

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).

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.