Home > Article > Web Front-end > A simple example of using DNode to implement communication between php and nodejs_node.js
1. Install DNode
1, for nodejs, execute
Execute the following statement to download composer
2. Use nodejs to create a simple server program, server.js
// This is the class we're exposing to DNode
class Temp
{
// Compute the client's temperature and stuff that value into the callback
Public function temperature($cb)
{
}
}
$loop = new ReactEventLoopStreamSelectLoop();
$dnode = new DNodeDNode($loop, new Temp());
$dnode->connect(7070, function($remote, $connection) {
// Remote is a proxy object that provides us all methods
// from the server
$remote->zing(33, function($n) use ($connection) {
echo "n = {$n}n";
// Once we have the result we can close the connection
$connection->end();
});
});
$loop->run();
?>