This month, I gave a talk about PHP and Node.js, at PHP Dev Conference Argentina.
I should write a post about my excellent experience in that conference, full of interesting topics and people.
My talk description
Where Node.js really shines and distinguishes itself from PHP is in realtime services. We will learn about its socket and websocket support, and how important true asynchronous IO is. We will also learn about the price we have to pay for this: callbacks.
But we don’t want to walk away from our beloved PHP, so we will integrate PHP with Node.js. First approach: PHP + browser + Node.js, with little communication between PHP and Node. Then we’ll jump right into integrating Node code from PHP. dnode modules (sync and async.) And before we end the session… surprises, and tutti li fiocci!
The slides are at:
The PHP code, at:
to be viewed from a web server (I used xampp in my notebook).
The node code, many servers to launch, each one listening by different ports:
You must install Node.js, and then, run “npm install” in that folder. For example, if you want to launch the distributed canvas server, execute at command line: “node canvasserver”.
There are examples where the browser connects with node.js server, without using PHP. And there are examples where the PHP code talks to Node.js. I used:
at Node.js side. And dnode PHP clients:
It can run minimal PHP code in the Node.js server: