APACHE/PHP-FPM VS
NODE.JS BUILT IN
WEB SERVER
Node.js runs as its own server. There is
no need to install third party software
PHP cannot run as a single web server.
Apache/PHP-FPM is must-have thing for
PHP in web environment
Both of them can run along with Nginx –
As a reverse proxy service
NODE.JS SIMPLE WEB
SERVER
PHP SYNTAX,
VARIABLES,
AND TYPES TO
NODE.JS
PHP SYNTAX,
VARIABLES, AND
TYPES TO NODE.JS
Both PHP and Node.js have common
roots in the C language
Both PHP and Node.js have:
+ if else
+ switch, case, and break
+ same conditional operators
+ the same String Literals: ‘ “ n
+ …
PHP SYNTAX,
VARIABLES, AND
TYPES TO NODE.JS
Difference:
Both PHP and Node.js have:
+ else if vs elseif
+ var, let, const instead of $
+ Node.js only have indexed array (no
associative arrays. Node.js object is
similar to php associative arrays)
+ Variable scope
+ …
CONVERT
BLOCKING PHP
SOURCE CODE
TO NON-
BLOCKING
NODE.JS
SOURCE CODE
CONVERT BLOCKING PHP SOURCE
CODE TO NON-BLOCKING NODE.JS
SOURCE CODE
PHP invented as a replacement for CGI
scripts:
+ Single threaded and is a step-by-step
model.
+ Multithread is depended on web server
JavaScript is an event-driven one:
+ Invented for browser work (Netscape
Navigator)
+ Designed for event handling
THE WORLD
OF
CALLBACK
THE WORLD OF
CALLBACK
A callback function is a function that
provided to another piece of code,
allowing it to be called by that code.
Why use callback function:
+ Javascript is async
+ Keep the flow correct (ex: open / write
/ close)
+ Asynchronous every thing you can
Problem of callback function
+ Complex code style
+ Callback Hell
SEPARATE NODE.JS
SOURCE. UNDERSTANDING
NODE REQUIRE
SEPARATE NODE.JS SOURCE.
UNDERSTANDING NODE
REQUIRE
+ Fundamental building blocks of the code structure
+ Help organize your code
+ Hide / expose the interface of a component
+ Use Node Require
NODE REQUIRE
+ Resolving: To find the absolute path of the file
+ Loading: To determine the type of the file content
+ Wrapping: To give the file its private scope. Give
require / module object to every file
+ Evaluating: This is what the VM eventually does
with the loaded code
+ Caching: So that when we require this file again, we
don’t go over all the steps another time
COMPOSER VS
NPM
THANK YOU

Difference between php and node

  • 1.
    APACHE/PHP-FPM VS NODE.JS BUILTIN WEB SERVER Node.js runs as its own server. There is no need to install third party software PHP cannot run as a single web server. Apache/PHP-FPM is must-have thing for PHP in web environment Both of them can run along with Nginx – As a reverse proxy service
  • 2.
  • 3.
  • 4.
    PHP SYNTAX, VARIABLES, AND TYPESTO NODE.JS Both PHP and Node.js have common roots in the C language Both PHP and Node.js have: + if else + switch, case, and break + same conditional operators + the same String Literals: ‘ “ n + …
  • 5.
    PHP SYNTAX, VARIABLES, AND TYPESTO NODE.JS Difference: Both PHP and Node.js have: + else if vs elseif + var, let, const instead of $ + Node.js only have indexed array (no associative arrays. Node.js object is similar to php associative arrays) + Variable scope + …
  • 6.
    CONVERT BLOCKING PHP SOURCE CODE TONON- BLOCKING NODE.JS SOURCE CODE
  • 7.
    CONVERT BLOCKING PHPSOURCE CODE TO NON-BLOCKING NODE.JS SOURCE CODE PHP invented as a replacement for CGI scripts: + Single threaded and is a step-by-step model. + Multithread is depended on web server JavaScript is an event-driven one: + Invented for browser work (Netscape Navigator) + Designed for event handling
  • 8.
  • 9.
    THE WORLD OF CALLBACK Acallback function is a function that provided to another piece of code, allowing it to be called by that code. Why use callback function: + Javascript is async + Keep the flow correct (ex: open / write / close) + Asynchronous every thing you can Problem of callback function + Complex code style + Callback Hell
  • 10.
  • 11.
    SEPARATE NODE.JS SOURCE. UNDERSTANDINGNODE REQUIRE + Fundamental building blocks of the code structure + Help organize your code + Hide / expose the interface of a component + Use Node Require
  • 12.
    NODE REQUIRE + Resolving:To find the absolute path of the file + Loading: To determine the type of the file content + Wrapping: To give the file its private scope. Give require / module object to every file + Evaluating: This is what the VM eventually does with the loaded code + Caching: So that when we require this file again, we don’t go over all the steps another time
  • 13.
  • 14.