Both NodeJS and PHP are two of the most widely used server-side technologies. Nonetheless, there are a lot of differences between the two leading backend technologies. While PHP is a programming language, NodeJS is a cross-platform JavaScript runtime environment.
Before moving on to differences between NodeJS and PHP, let us first take a brief look at both the technologies.

PHP
Created by Rasmus Lerdorf, PHP made its debut sometime in 1995. Originally, PHP meant Personal Home Page but now it is a recursive backronym for PHP: Hypertext Preprocessor. The open-source, server-side scripting language is developed specifically for web development.
Unlike other popular programming languages, PHP evolved without a written formal specification up until 2014. The original implementation of the programming language acted as the de facto standard up until that point.
Though PHP is a server-side scripting language, it can also be used for other purposes. PHP scripts has a .php extension and contains a combination of CSS, HTML, JavaScript, and even plain text. As of now, PHP is one of the leading programming languages to get a job.
Facebook, Flickr, Wikipedia, Yahoo, and Tumblr are some of the leading names that have been built using the PHP programming language.

Node Js
Node.js was created by Ryan Dahl in 2009 which enabled building backend application with javascript rather than using the traditional technologies – PHP, C#, Python or PERL. This made it possible to build an application with a single language across the stack. Node.js is built on Chrome’s V8 JavaScript engine and known for being asynchronous, event-driven and nonblocking.

PHP vs NodeJS

To make the comparison between PHP and NodeJS easy to understand, we have divided the complete section into various categories:

Program Type (Synchronous and Asynchronous)
One of the key difference that separates the PHP and Node.js is the way they execute the codes.
PHP has been known for synchronous execution of codes. As per the term suggests this backend language executes the codes in sequence (synchronization), so it doesn’t matter how long a function takes to execute, it won’t move to the next one until it’s completed.

Database Preference
More often than not, PHP is used with traditional or relational databases to the likes of MariaDB, MySQL, and PostgreSQL. Though there are ways to use NoSQL databases with PHP, doing so is not so frequent in the industry.
Though NodeJS works fine with SQL databases, the trend is shifting towards using NoSQL databases, such as CouchDB and MongoDB.

Frameworks
Frameworks have made life easier by speeding up the development process and helping developers to write structured, reusable and maintainable codes. So, while considering between PHP vs Node.js, frameworks play an important role.
When it comes to PHP, there is a huge list of frameworks at your disposal. Just name it – Laravel, Codeigniter, Symphony, CakePHP, FuelPHP, Phalcon and the list goes on.
When it comes to Node.js, we see a growing number of frameworks along with its growing community. Although you may not get the options as varied as PHP, some of the well-known frameworks are – Express, Meteor.js, DerbyJS and Sails.js.

Development Stacks
While writing back-end code in PHP, the developer frequently switches between different programming languages. This is due to the fact that PHP is mostly used as a part of the LAMP (Linux, Apache HTTP Server, MySQL, and PHP) stack.
NodeJS, on the other hand, typically uses either MEAN (MongoDB, Express.js, AngularJS, and NodeJS) or MERN (MongoDB, Express.js, React, and Node.js) stack. The only programming language knowledge required for using the entire stack is JavaScript.

Webserver Setup
PHP versions prior to v5.4 required downloading and setting up LAMP and XAMPP servers. However post that, PHP comes bundled with an inbuilt development server.
NodeJS, on the other side, comes prepackaged with core modules, including the file system, HTTP, and DNS. These help in developing customized web servers.