Looking for more information on how to do PHP the right way? Check out PHP: The Right Way

Henri Bergius' Blog:
DNode: Make PHP And Node.Js Talk To Each Other
Oct 31, 2011 @ 09:50:05

Henri Bergius has a new post to his blog today sharing details about a messaging protocol that can help PHP and Node.js play together nicely - DNode.

Both environments have their strong points. Node.js is very fast and flexible, but PHP has a lot more mature tools and libraries available. So in a lot of projects it is hard to choose between the two. But now you might not have to. DNode is a remote method invocation protocol originally written for Node.js, as the name probably tells. But as the protocol itself is quite simple, just sending newline-terminated JSON packets over TCP connections, implementations have started popping up in other languages. You can talk DNode in Ruby, Perl, Python, Java, and now PHP.

He includes a quick example of both sides of the messaging - a simple server on the Node.js side that looks for a DNode request and using the dnode PHP client to connect to it (and return the input number multiplied by 100). He also includes a method that allows for bidirectional communication with a service that converts from Celsius to Fahrenheit.

tagged: dnode nodejs communication bidirectional dnodephp

Link: