I have a cloud of virtual servers: one running php, one running node.js, one running mongodb.
Dnode has successfully passed messages between the php and node using this guide.
<?php
// Include Composer-generated autoloader
require(__DIR__.'/vendor/autoload.php');
// Fed from NODE Server
$mongo = new React\EventLoop\StreamSelectLoop();
// Connect to DNode server running in port 7071 and call query to display
$dnode = new DNode\DNode($mongo);
$dnode->connect(7071, '192.168.15.29', function($remote, $connection) {
$remote->MongoQ(use ($connection){
echo;
$connection->end();
});
});
$mongo->run();
?>
Node has successfully connected to mongo using this guide.
//Retrieve
var MongoClient = require('mongodb').MongoClient;
// Connect to the db
MongoClient.connect("mongodb://192.168.15.26:27017/mongotest", function(err, db) {
if(err) { return console.dir(err); }
var collection = db.collection('usercollection');
collection.find().pretty()
});
});
// Feed to PHP Client
var dnode = require('dnode');
var server = dnode({
MongoQ: function() {collection.find().toArray(function(err, items) {});}
});
server.listen(7071, '192.168.15.29');
console.log('Server running at http://192.168.15.29:7071/');
I'm completely lost as to what to do on the PHP side once I've called the function that queries my mongo collection.