PHP is not even close to dying.

PHP has a bright future, even against the fancy new techs, here is why.

Edouard Courty
5 min readJul 25, 2022

Hating on PHP has been very common inside the web development community for years now.

It almost became fancy to hate on PHP and glorify newer technologies these days, like Node.JS, even with no real arguments, especially in the younger community where PHP is considered “a dinosaur”.

PHP is a great language.

It’s not perfect and has its pros and cons, but overall, if you’re working in web development, you’d better try to understand it instead of following the tendency and simply hate it because some people do…
You might even learn something by doing so!

Node & PHP’s respective logos

Let’s go through the differences between PHP and Node.JS that keep lots of people writing PHP these days, and the ones that push others to different languages!

  • Community

The PHP community is larger than the Node.JS community.
The NPM/Node community is quite big but suffers from a lack of people actually maintaining their packages and doing a good job at it.

Lots of modules are deprecated and/or not up-to-date. The worst thing is most modules rely on a massive amount of dependencies, meaning if a module you use relies on an old module that contains a vulnerability, you might not know it or spend more time updating everything yourself.
It’s important because no matter how good a language/framework is if no one works with it if there are no discussions / PRs / open source projects around it, it will die.

The PHP ecosystem has an enormous amount of libraries that will help you: JWT authentication, generating Excel spreadsheets and PDFs, cache management, ORMs… These libraries are widely used, secure, and very well documented.
Symfony even has official documentation for some of them, like LexikJWTAuthentication!

In fact, ~80% of the web runs on PHP.

  • Frameworks

Symfony & Laravel, the two major PHP frameworks are an enormous part of the web at this moment. Laravel is very popular in the US and Symfony in Europe, and these two frameworks alone count for more than 90% of the PHP ecosystem if we remove WordPress from the list.
These frameworks are older than most of Node.JS’s frameworks, and have a wider ecosystem of bundles/packages and documentation than every single Node.JS-based framework has nowadays.

Have an issue with Symfony? Version 3? Version 4? That’s not a problem! There are plenty of StackOverflow / Medium / Official doc pages ready to help you.

Symfony & Laravel also provide some kind of “base project structure”, you can of course get rid of it and build your project in the way you want, but the base pattern is usually good for a lot of kinds of apps.
They can also be tweaked using the configuration in most cases to suit your needs very carefully. As these frameworks have been out for some years, most of the useful features that you might think of already exist, because some other developers before you had the same needs.
If we take the example of Express.JS, Node’s most famous frameworks, mostly used to write APIs, do not come with a mandatory structure. The lack of infrastructure means that a non-experienced developer has more chances to create something that does not really comply with the standards when our PHP frameworks have less risk.

  • Performance

Node.JS is fast, sometimes faster than PHP in some cases, but PHP is not too bad.
On the first hand, PHP 8.1 takes advantage of OPCache & JIT compiling to get faster execution times.

On the other hand, Node takes advantage of its asynchronous nature when it comes to speed, but is also single-threaded, whereas PHP takes advantage of running on multiple threads, but synchronously.

In fact, server prices are not very high in general, and scaling a web app has never been easier than today. Performance is not really a good argument anymore when it comes to small web apps, seeing the available computational power these days.

However, when it comes to large-scale apps, the price can be an important point.

That’s why swapping to the usual PHP-FPM / Nginx stack to Swoole can be a good choice.
I’ve seen apps beating Node.JS with Swoole as the underlying HTTP server for their PHP apps!

Also, using message queuing is a great way to balance the load of the heavy tasks that your app has to do, and can be implemented in PHP and Node pretty easily, here is a tutorial I wrote about Message queuing.

  • Usage

While Node / Express is often used to write APIs and communicate with a front-end that would be built using a framework such as React / Angular / Vue… Most PHP frameworks work with the MVC pattern.
MVC stands for Model — View — Controller. As a schema is usually better than a long speech: here is a quick schema to understand MVC if you’re not familiar.

MVC Overview — By @joespinelli_6190

Building an app with a separate front/back is usually slower than working on a single stack handling the front & the back. In fact, many back-end developers know how to write good HTML / CSS but are not familiar with the concepts or syntax used by React or the other frameworks.

  • Conclusion

Both PHP and Node have pros and cons.

If you need stability, reliability, and long-term support for a service, I’d suggest using PHP.
The frameworks are mature and safe to use, making it the #1 choice in my opinion.

However, Node is a good choice for APIs with high throughput and real-time data handling, there are also projects that cannot really be done in PHP, like a Discord bot (It’s possible in PHP but there is an official JavaScript library to do it so…).

It’s also great to write an app in another language sometimes, it usually allows me to discover new concepts or ways of doing something that I can then apply to my other favorite language.

If you like my content and want to get updates on my future articles, feel free to follow my account!

--

--

Edouard Courty

Web Developer & IT Teacher based in Paris - Back-end guru - Co-founder of @IMXrarity