News Feed
Sections




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

Francois Zaninotto's Blog:
Node.js for PHP Programmers #1 Event-Driven Programming... and Pasta
January 26, 2012 @ 08:35:41

On his blog today Francois Zaninotto has a post that aims to introduce those with a PHP background to how Node.js works. In this first part of his series, he tries to explain the idea of event-driven programming - parallel processing of different parts of an application based on some action taken in the code.

For a PHP developer, asynchronicity is the most puzzling aspect of the Node.js runtime. It's simply a new way to write programs. And once you pass the first learning steps, event-driven programming opens a world of possibilities PHP programmers would never dream of. I'll try to explain you how it works, but first, let's talk about pasta.

In his "pasta" example, he shows how a typical PHP application would make a "Pan" object, call a "warm" action, "add olive oil", etc. All of this happens in sequence, though and takes 29 "minutes" to complete. To help things along, he implements an "EventLoop" class that handles tracking the timing and includes two methods to execute callbacks and delayed methods. He expands on this example with asynchronous objects and method calls to handle multiple things at once. He relates this to what Node.js offers - a built in event handling system, an included EventLoop object and native blocking I/O operations.

0 comments voice your opinion now!
nodejs programmer eventdriven pasta asynchronous


blog comments powered by Disqus

Similar Posts

Gonzalo Ayuso's Blog: Speed up PHP scripts with asynchronous database queries

Site News: Blast from the Past - One Year Ago in PHP

Site News: Job Postings for the week of 04.19.2009

Job Posting: Bayser Consulting Seeks Analytical Programmer (Skokie, IL)

Community News: Packagist Latest Releases for 07.02.2014


Community Events





Don't see your event here?
Let us know!


language tool security laravel version release symfony community introduction voicesoftheelephpant composer library framework artisanfiles list series conference opinion podcast interview

All content copyright, 2014 PHPDeveloper.org :: info@phpdeveloper.org - Powered by the Solar PHP Framework