PHP is Legacy, in 2024
最后更新 November 19, 2024

We travel in our jobs a lot at Vonage. I speak to plenty of developers from all walks of life, and I can confidently say one of the most asked questions I get is: Why do you still do PHP? Variations of this question can be "Isn't PHP supposed to be bad?" On several occasions, the person I was speaking to had done some PHP back in 2012. Or 2010. I forget. For reasons I do not understand, we're going through another spate of this within online forums a lot, and so more "PHP is terrible" comments are coming out of the woodwork.

What causes this phenomenon? Why is PHP “bad”?

Tribes

I regard most developers as people that start out as nomads, that end up “finding their tribe”.. This is, after all, essentially what tech communities are. One of the difficulties starting out (aside from landing your first role) is being accepted or choosing which tribe you wish to call home. Getting accepted feels difficult to some, and this is where common ground or humour can be used for graduates or boot campers.

In this respect, the well-known joke is "PHP is bad." But there's no reasoning behind it anymore - the closest someone will probably give as an explanation is a massive rambling blog post written years ago about many, many things that you will never encounter or are only an annoyance to its author. It doesn't matter that counter-posts have come out such as this one from Slack Engineering that explain the nuance that any application can be written badly in any programming language. I guess some might be quick to point out that Slack originally built their platform with Hack, a Facebook-created fork of PHP or that many of the new services they’ve added since are in Go or Node. 

So, the stage is still set: it's bad.

The Self-Perpetuating Myth

PHP is so bad, in fact, that a certain Operating System decided to issue a warning when attempting to use the version that shipped with it, stating:

WARNING: PHP is not recommended

Regardless of the fact that the version that was shipped with it was already out of date, people defended the phrasing here by explaining that the intention was to warn people about the legacy version of PHP that the Operating System shipped with. 

It was found to have done the same with Python 2.7, but crucially, the error message explicitly said “Python 2.7 is not recommended”. That isn’t what this error message says. One cannot help but feel that this was almost done with a little nudge and wink. Smiles all round.

Some people might find that funny, but I don't find any humour in my Operating System telling me what programming language I should use. This is the self-perpetuation of PHP being bad, and why this nudge, nudge wink is OK.

So, why are we still talking about PHP if it's supposed to be bad?

Necessity is the Mother of Invention

There is one other programming language that has followed the exact pattern of evolution, and that is JavaScript. As JavaScript was the de-facto language running inside a browser with a built-in engine, it had to evolve from basic beginnings.

Similarly, because of the rise of Content Management Systems being backends that were written in PHP such as WordPress and Drupal: PHP had to evolve. Evolution of a language from Rasmus Lerdorf's handy C hack for his own scripting usage into a fully-fledged general programming language designed for the web does not happen by accident. It's happening because people use it, in the same way that the JavaScript and ECMAScript relationship and ecosystem tooling constantly evolve.

This evolution has happened precisely because PHP is still being so widely used - without it’s widespread use we would never have seen things like the move to a full Object Oriented class system in 5.0, traits in 5.4, the introduction of generators in 5.6, a reworked engine in PHP7 that saw a performance boost of 100% in some cases, a JIT compiler for 8.0 and native enums in 8.1. Perl's lifecycle, for example, did not see it quickly evolve because people stopped using it. So what are actual results of this evolution that we are seeing today?

PHP does not scale.

Try telling that to Fathom Analytics, who rewrote their application in Laravel and deal with millions of requests per second.

Let's clear this up: any microservice or distributed system will not scale effectively if you design it poorly

Fathom's case shows that you can do this - in their case, within the Laravel space - very effectively with an arsenal of tooling that comes from Laravel. As Jack mentions in the blog post above, the criticism from programmers using other languages is that PHP cannot scale because benchmarks say so. 

But, when you're building an application at scale, are you going to need it to handle 1 million requests per minute? Probably not. But it certainly would be nice and fast in Node because it's asynchronous, right? Probably. Do you care? Unlikely at this stage.

PHP is slow

A common criticism is that because PHP is single-threaded, you have to spawn new processes to create concurrent work or horizontally-scaled workloads. The PHP-JIT was introduced back in PHP8.0, but that was only really the start of changes that made speed the primary agenda for PHP’s evolution. I was introduced to OpenSwoole (then Swoole) as far back as 2014, and saw an extension workaround for the single-threaded issue. The advent of native Fibers in PHP8.1 then meant that coroutines/asynchronous PHP could be achieved. A good example of some benchmarking can be found here, but the summary of this evolution to speed means that there are now several options for PHP developers to write applications at lightning speed.

Fiber Coroutines

ReactPHP and amphp are two examples of using fibers for non-blocking asynchronous PHP and aren't even new. These run effectively like the event loop in Node. If you want to check out what kinds of speeds you can get out of these, here is an example from one of ReactPHP's core team, Cees-Jan Kiewiet. Spoiler: it's fast.

New Runtime

So, we're not counting Roadrunner and OpenSwoole as they aren't new. But remember when I said necessity is the mother of invention? Well, this year saw something quite astonishing:A new PHP Application Server launched, FrankenPHP. 

Why is it called FrankenPHP? Because the need for PHP evolution has resulted in the new runtime being coded in Go, similarly to Roadrunner, only this was built on top of the Caddy web server. Does it make sense? Perhaps it looks strange, so no. Is it fast? Yes. Do you care that it's in Go? Hopefully not. Here's an example of FrankenPHP being used by Laravel Octane. Spoiler: it's fast.

Where did FrankenPHP Come From?

Image Credit: FrankenPHP https://frankenphp.dev/

The creator of FrankenPHP is Kévin Dunglas. What is interesting to note is that Kévin is a core member of the Symfony Framework, so one could argue that Symfony has effectively sponsored the creation of a new, faster PHP runtime by sponsoring his work

There is another reason to check out Kévin's work though, in that he is also the creator of API Platform.

Hang on, What is API Platform?

Image Credit: API Platform https://api-platform.com/

Ah, right, glad you asked. Well, PHP is so legacy that you can now use a bespoke backend framework that is designed solely for the rapid development of REST/graphQL web APIs. It can be used with either Symfony or Laravel, and contains features such as selecting your API response standards, automatic documentation handling with OpenAPI or SwaggerUI, automated testing tooling and performance/cache handling. Web API from prototyping to production? 

Spoiler: it's fast.

Community Notes: Bigger and Bigger

Photo Credit: DrupalCon Barcelona 2023 Attendees

https://events.drupal.org/barcelona2024

A common line said to me every year by developers is that PHP usage (and therefore PHP development) is shrinking each year. This coincides every single year with the release of the StackOverflow developers' survey. I think it's important to know that the much-trotted out figure of 70% (or around there) of the web being PHP is because of WordPress. Yes, it's PHP, but it's the success of WordPress as a product that makes that figure so. With such an inflated figure, it's only bound to go down over time as more and more CMS frameworks and even CMS SaaS Cloud products such as Contentful or Strapi increase their usage.

So is PHP usage fading? Numerically, yes, as users move from WordPress but the communities of PHP are still incredibly strong. The usage of three of its major frameworks is increasing, meaning new projects are being developed. DrupalCon averages about 3000 attendees per conference, where several are held per year across the world. SymfonyCon and Laracon are also both held worldwide, several times a year and average numbers between 1000-3000 attendees. That, to me, does not show a dying language. It's showing a growing one.

Maybe People Are Starting To Notice?

People say that imitation is the highest form of flattery. With that philosophy in mind, it's worth noting that Laravel's approach to full-stack development (itself originally based on Rails) has spawned fully featured frameworks outside of the PHP space. Meet AdonisJS, a Node Framework based on Laravel. Not enough? Here, have Wasp, also a Node Framework based on Laravel. How about Goravel, a Go framework based on... well, I think we know what's coming.

Laravel's specific approach to the Developer Experience is what has earned it a loyal following of developers. So much, in fact, that tech influencer ThePrimeagen raised an eyebrow at Aaron Francis’s video PHP Doesn’t Suck Anymore and checked it out. The results were an unexpected endorsement. A keynote from him at LaraconUS this year topped this off until the moment that Laravel announced they'd raised $58 million in venture capital. You might have approached this article thinking that PHP is dying, but with these sort of comings and goings, I would say perhaps not.

The thing is, all this framework talk is good and all, but… who evolves the PHP Language?

The PHP Foundation

Hopefully, if you are not a PHP developer, then I might have got your attention in this article. So, for a bit of background: for years, PHP was maintained by one man, Nikita Popov, through the sponsorship of JetBrains. Yes, there was a decent amount of support from release managers too numerous to mention, but that is still a lot of work on one developer’s plate for features. In 2022, The PHP Foundation was set up, which currently has a board consisting of PHP veterans and representatives from Automattic, Private Packagist, JetBrains, Tideways, Perforce and Symfony.

The Foundation pays for 10 engineers - some full-time, some part-time. It’s pretty rare to have this sort of open-governance, when the most common setups are “the benevolent dictator for life” or commercially-backed. This journey cannot continue without them, so if you want to see where this 30 year journey continues, then you can check out https://thephp.foundation/sponsor/ to help the language on its next iteration.

Conclusion

I don’t know why we’re seeing a resurgence of “lolphp” around the corners of the internet, but frankly, I’m not exactly worried. I do think, however, that it is somewhat limiting developers’ abilities when parroting lines about something being bad, which has likely come from someone most likely writing the language 15 years ago. PHP is modern, looks totally different to 15 years ago and has a thriving community and tooling system. Things such as PsalmPHP and PHPStan static analysis courtesy of the Abstract Syntax Tree, are absolutely first-rate tooling. If some of the biggest tech influencers out there are willing to give it a go, then why not you? You can get started with trying out Vonage communications by fetching the Vonage PHP SDK, which I am the core maintainer for. Need help? You can join our community Slack or hit us up on X. Need guidance? You can book a short session with me.

James SecondeSenior PHP Developer Advocate

A trained actor with a dissertation on standup comedy, I came into PHP development via. the meetup scene. You can find me speaking and writing on tech, or playing/buying odd records from my vinyl collection.

Ready to start building?

Experience seamless connectivity, real-time messaging, and crystal-clear voice and video calls-all at your fingertips.

Subscribe to Our Developer Newsletter

Subscribe to our monthly newsletter to receive our latest updates on tutorials, releases, and events. No spam.