PHP and Node.js

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

We will see what Node.js means for a PHP programmer. A programming language built on top of Google’s V8 engine. Executing loops, with asynchronous IO. Node.js as a shell server, and web server. Javascript as a very flexible language, with little of the programming bloatware that’s common on other languages. A package ecosystem, very similar to PHP’s Composer. Instead of dealing with lots of functions (as we are used to with PHP), Node has modules, that we can install and utilize at any point.

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:

At the end of the talk, I presented my PHP-to-JavaScript transpiler, written in JavaScript:

It can run minimal PHP code in the Node.js server:


Keep tuned!

Angel “Java” Lopez

2 thoughts on “PHP and Node.js

  1. Pingback: New Month’s Resolutions: November 2013 | Angel "Java" Lopez on Blog

  2. Pingback: Resoluciones del Nuevo Mes: Noviembre 2013 - Angel "Java" Lopez

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s