If you're an experienced PHP developer, you already have a head start on learning how to write Node.js code. In this book, author Daniel Howard demonstrates the remarkable similarities between the two languages, and shows you how to port your entire PHP web application to Node.js. By comparing specific PHP features with their Node counterparts, you'll also discover how to refactor and improve existing PHP 4 or PHP 5 source code.
At the end, you'll have two fully functional codebases to provide to your users. You can update both of them simultaneously, using this book as a reference to important aspects of PHP and Node.js.
* Use a simple Node.js framework to convert individual PHP pages to Node.js files
* Refactor blocking PHP source code to non-blocking Node.js source code that uses callbacks
* Convert PHP syntax, variables, and types to Node.js
* Use a step-by-step technique for implementing PHP classes and class inheritance in Node.js
* Convert PHP file handling APIs into their Node.js equivalents
* Compare approaches for using a MySQL database in Node.js and PHP
* Convert PHP code for JSON or XML APIs into Node.js code for npm packages
Sprache
Verlagsort
Zielgruppe
Produkt-Hinweis
Broschur/Paperback
Klebebindung
Maße
Höhe: 232 mm
Breite: 179 mm
Dicke: 20 mm
Gewicht
ISBN-13
978-1-4493-3360-7 (9781449333607)
Schweitzer Klassifikation
Daniel Howard has worked as a software developer for over 15 years. He has worked at startups, Fortune 500 companies, and several in between. He has seen companies and individual developers struggle to move from one technology to another. He believes everybody can keep one foot firmly planted on one side and plant his other foot in the new technology, and wants to help them learn how to do so.
Preface;
The Mission;
Who I Am;
This Book;
About This Book;
Conventions Used in This Book;
Using Code Examples;
Safari® Books Online;
How to Contact Us;
Acknowledgments;
Chapter 1: Node.js Basics;
1.1 The node and npm Executables;
1.2 Stack Traces;
1.3 Eclipse PDT;
Chapter 2: A Simple Node.js Framework;
2.1 An HTTP Server;
2.2 Predefined PHP Variables;
2.3 A PHP Example Page;
Chapter 3: Simple Callbacks;
3.1 Linearity;
3.2 Making Code Linear;
Chapter 4: Advanced Callbacks;
4.1 Anonymous Functions, Lambdas, and Closures;
4.2 PHP 5.3;
4.3 PHP 4;
Chapter 5: HTTP Responses;
5.1 Headers;
5.2 Body;
5.3 A PHP Example Page;
Chapter 6: Syntax;
6.1 String Literals;
6.2 Syntax Differences;
6.3 PHP Alternative Syntax;
Chapter 7: Variables;
7.1 Simple Variables;
7.2 Array Variables;
7.3 Other Variable Types;
7.4 Undefined Variables;
7.5 Scope;
Chapter 8: Classes;
8.1 Encapsulation;
8.2 Inheritance;
8.3 PHP parent and static Keywords;
Chapter 9: File Access;
9.1 Reading and Writing Files;
9.2 PHP file() API Function;
9.3 Low-Level File Handling;
9.4 Filenames;
Chapter 10: MySQL Access;
10.1 Database Approaches;
10.2 node-mysql;
Chapter 11: Plain Text, JSON, and XML;
11.1 Plain Text;
11.2 JSON;
11.3 XML;
Chapter 12: Miscellaneous Functions;
12.1 Array;
12.2 Time and Date;
12.3 File;
12.4 JSON;
12.5 Math;
12.6 String;
12.7 Type;
12.8 Text;
12.9 MySQL;
12.10 Variable;
12.11 php.js License;
Colophon;