PHP vs Node.js—what’s the difference? Both power the backend of dynamic websites, but with distinct differences.
WHAT IS PHP?
PHP (Hypertext Preprocessor) is a general purpose scripting language that quickly became the de facto server-side language of choice for web developers after its initial release in 1995. Today, a majority of sites on the web run on PHP, due in large part to its popularity as the language of choice for content management systems (CMS) like WordPress, Drupal, and Joomla and a number of modern frameworks like Laravel, Symfony, and CakePHP that have accelerated development with this mature language.
WHAT IS NODE.JS?
PHP VS NODE.JS: MAJOR SIMILARITIES
There are some top-level similarities to consider when deciding which back-end technology is best for you.
PHP VS NODE.JS: MAJOR DIFFERENCES
- PHP is simpler. PHP is conceptually much simpler to use than Node.js. When setting up a server, all you need is a “.php” file with some code wrapped between the tags, enter the URL into your browser, and you’re done. Behind the scenes, a web server like MySQL with PHP installed will be able to interpret the file and display your web page in your browser. Setting up a Node.js server, while not difficult, usually requires more lines of code, and a basic understanding of how closures and callback functions work.
WHEN SHOULD YOU USE PHP OR NODE.JS?
You should consider PHP if your project involves…
- Software stacks like the LAMP stack (Linux, Apache, MySQL, PHP)
- CMS’s like WordPress, Drupal, or Joomla etc.
- Servers like MySQL, SQL, MariaDB, Oracle, Sybase, and Postgresql etc.
You should consider Node.js if your project involves…
- Software stacks like the MEAN stack (MongoDB, Express.js, AngularJS)
- Dynamic single page applications (SPAs)
- Front-end technologies like jQuery, AngularJS, Backbone.js, Ember.js, ReactJS etc.
- Server-side technologies like Node.js, MongoDB, Express.js, etc.
Keep in mind that neither list is extensive. These are only meant as a starting point to help you get a feel for what you can expect and what keywords you can use to assess the best language for your needs.
Source viva: https://www.upwork.com/hiring/development/php-vs-node-js/