Angel \”Java\” Lopez on Blog

October 30, 2013

PHP and Node.js

Filed under: JavaScript, NodeJs, Open Source Projects, PHP, Talks — ajlopez @ 4:37 pm

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


  1. […] Give a talk about PHP and Node.js [complete] see post and PHP/Node repo and PageJs repo at PHP Dev Argentina 2013 – Give a talk about TDD with ASP.NET […]

    Pingback by New Month’s Resolutions: November 2013 | Angel "Java" Lopez on Blog — November 2, 2013 @ 1:49 pm

  2. […] Dar una charla sobre PHP and Node.js [complete] see post and PHP/Node repo and PageJs repo at PHP Dev Argentina 2013 – Dar una charla sobre TDD con ASP.NET […]

    Pingback by Resoluciones del Nuevo Mes: Noviembre 2013 - Angel "Java" Lopez — November 5, 2013 @ 10:54 am

RSS feed for comments on this post. TrackBack URI

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 )

Google+ photo

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

Connecting to %s

Blog at

%d bloggers like this: