PHP and Node.js

Two worlds, more power

Created by @ajlopez

https://github.com/ajlopez/Talks/PhpNode

Using reveal.js

Agenda

  • Node.js
  • PHP + Browser + Node.js
  • PHP + Node.js
  • Compiling PHP to JavaScript

Node.js

http://nodejs.org/

Node.js

  • JavaScript Runtime
  • Based on Google V8 JavaScript Engine
  • One thread for JavaScript
  • Asynchronous operations via LibUv
  • Native Modules
  • Module Ecosystem
## A Web Server ```js var http = require('http'); http.createServer(function (req, res) { res.writeHeader(200, {'Content-type': 'text/plain'}); res.write('Hello '); res.end('World'); }).listen(8000); ```

Vibrant Community

Express

http://expressjs.com/

Express

  • Web Framework
  • Based on Connect
  • MVC routing and views
  • Minimalist

Node Cellar

More info

PHP AND Node.js

Integration via Browser

Distributed Node.js

Intermediate

PHP calling Node.js

Socket.IO

http://socket.io/

Socket.IO

  • Persistent Connection btw Client and Server
  • Real Time
  • Browser support
  • WebSockets or fallback

Handshake

http://www.slideshare.net/3rdEden/going-real-time-with-socketio

DNode

https://github.com/substack/dnode

DNode

  • Asynchronous Remote Procedure Call
  • Client and Server
  • Node.js vs Node.js
  • Using Sockets and Messages
  • Libraries for Other Languages
  • And YES! PHP!

DNode for PHP

Things to Explore

THE END

BY Angel 'Java' Lopez / www.ajlopez.com / @ajlopez