PHP or Node.js for your web project: how to choose

If you are installing WordPress, a shop or another ready-made program, use PHP: it is what the program asks for. If you are writing an application of your own, with real-time features or an API, and your team knows JavaScript, Node.js is a good choice. It is not a question of which is faster: both serve huge sites. It is a question of what the project needs and what your team masters.

On our shared hosting both exist. PHP is chosen per folder, in Select PHP Version. Node.js is chosen application by application, in Setup Node.js App, with several versions to pick from. See which technologies run here.

The difference that explains almost everything

In PHP, every request starts the script, which runs, answers and ends. Nothing stays in memory from one request to the next; whatever has to last goes into the database, into files or into the session. In Node.js, the application is a program that keeps running and serves many requests at once. It can keep things in memory, hold connections open and react to events, but it also has to be started, restarted after every code change and watched.

Side by side

Criterion PHP Node.js
Going live Upload the files and it works. Register the application, give the startup file and start it. See getting a Node.js application running.
Ready-made programs Many: WordPress, Joomla, shops and most CMSs. Fewer classic CMSs; many developer tools and applications.
Real time (chat, notifications) Possible, but not its strong point. Natural: open connections and events.
Language PHP on the server, JavaScript in the browser. JavaScript on both sides.
Code changes Take effect on the next request. Need the application to be restarted.
Upkeep Pick the PHP version and keep up with it. Pick the Node version and keep up with the npm dependencies.

How to decide

1 Using a ready-made program? The program decides. WordPress, WooCommerce, Joomla or Moodle are PHP.
2 Writing a new application? Choose the language whoever will maintain it knows best. That knowledge is worth more than any difference between the two.
3 Need open connections or live updates? Node.js is more natural. On shared hosting test carefully, because open connections take resources; on a VPS you have full control. See shared hosting vs VPS.
4 Already have a PHP site that works? Do not rewrite it for fashion. Rewriting costs months and rarely brings the visitor anything they notice.
Node.js on a shared account has limits. The application serves web requests through your domain; it does not open ports of its own or install system services. If the project needs that, the route is a VPS. See Node.js in cPanel: choosing the version and using npm and, if the application answers with a 503 error, the usual causes.
You can use both. A PHP site on the main domain and a Node.js API on a subdomain live together on the same account. Each does what it does best.

Have a project and not sure it fits on shared hosting? Describe it and we will tell you what suits.

Open a support ticket

SEE ALSO

Which technologies run here: PHP, Node, Python, Perl, games and the limits

Getting a Node.js application running

Shared hosting vs VPS: which one does your project need?

VPS server

RECOMMENDED PRODUCT

Web hosting with cPanel

Domain and SSL included, daily backups and the panel you already know. from 5.940,00 Kz/mo (3-year plan, with coupon)

See plans
  • 0 Users Found This Useful
Was this answer helpful?