Stop Saying PHP Is Dead.

It isn’t. PHP is not dead. It isn’t dying and it isn’t reaching “end-of-life”. That’s it. No matter how much some people want it to go away, it isn’t going away. At least, not for a long time.

Warrick Bayman
Dec 2, 2020 · 13 min read
Image for post
Image for post
Photo by Ian on Unsplash

I’ve been writing this for a while now. Tweaking here and there, but just couldn’t decide when to publish. With the recent release of PHP 8, “now” felt like the right time.

Every month I read an article, or a comment or tweet stating that PHP is dying and we should stop using it. If you see a question on some or other forum or on Stack Overflow about learning PHP, there is an almost 100% chance that there’s a response from someone saying something like: “why would you want to learn PHP? Learn something cool like <insert-cool-language-that-isnt-php-here>”.

I have spent close on 20 years writing stuff in PHP (actually, it might be more. I don’t truly remember when I started), among other languages, and, for the most part, I have simply ignored much of that side of the conversation. For almost all of those years, PHP has been “dying” and I should’ve stop using it years ago. I am by no means an expert in any of the languages I use, and I have plenty to learn about PHP, yet time and time again, I find myself coming back to it.

I’ve spent plenty of hours learning other languages when I was almost convinced by the occasional well written anti-PHP piece. And I’ll admit that those adventures yielded great results. Although I’ll likely never use many of them professionally, I learnt so much about being a programmer just by learning another language.

If there’s one thing you take from this post, it should be: “learn another language”, but not because “php is dying” – It’s just not true. You should learn another language because it’s good for you as a programmer. If PHP really was dying, then sure, you’d have a reason to move on, but right now, in this moment, it isn’t dying.

One of the first things that many PHP programmers will bring up when trying to defend their choices, is one of those graphs showing how popular PHP is around the web. Although those numbers are very interesting I have a tendency to believe that they’re a bit misleading. It would be a mistake to ignore the fact that PHP is popular because of the likes of WordPress. Love it or hate it, WordPress is the reason we’re all here. But WordPress is… well… WordPress. It has many (and I mean many) faults, but I know (and am friends with) plenty of people who make a great deal of amazing things – And plenty of money – using WordPress.

PHP is not WordPress. And, although WordPress is firmly cemented into PHP’s history book, PHP is better than WordPress – MUCH better. There’s a lot wrong with WordPress and there’s a lot wrong with PHP, but that doesn’t mean its a bad choice for every project. I probably wouldn’t be writing my web applications in C++ (or at least it would be WAY down the list of languages for those projects), but that doesn’t make C++ a bad language. It’s just not suited for that job in the same way that I wouldn’t be using PHP to write hardware drivers or anything to do with AI. it’s just way outside of its wheelhouse.

Choice of language also has a lot to do with what you know. As the old adage goes: time is money, and in most cases, taking on a new language for a project is a big undertaking that would put more strain on timeframes which are usually already tight. I know PHP fairly well so it’s often going to be my first choice. I know a little Python, but I’m way better with PHP. I could probably do the same things in Python, but it’s going to take me twice as long, (at least in the beginning). It doesn’t mean I won’t use Python at all, or that I have anything against Python, it just means that PHP is my go-to.

Learning a language isn’t actually that hard and an experienced programmer might be able to pick up the gist of a language in a weekend. But that doesn’t mean they know the language. Knowing a programming language isn’t just about knowing which built-in function does what, it’s about having enough experience to know WHEN to use what features, or how the ecosystem fits together.

I know PHP, but I also know how to set up an Nginx web server and how to configure FPM or opcache; I have enough knowledge to make smart choices about dependencies; I know how to securely deploy PHP applications in production and I’m aware of security problems that could be introduced if I’m not careful with how I use certain language features. These things are more than just “knowing” a language. As programmers we invest a large amount of time in learning these things that often sit outside of the languages we choose.

That’s why it’s really disappointing when another programmer, tells me my choice of language is “shit”. I’ve spent 20 odd years getting better at this bit of technology, but now this one person is telling me that my choice was wrong?

Well, it’s not wrong. PHP has giving me a career I am happy with. I live in a nice house and drive a great car because I spent 20 years getting really good at this one thing.

But I digress. This was supposed to be about how PHP is not crap.

A lot of the “we hate PHP and think it should die” crowd bring up a number of things that they think make PHP an all-round bad choice. Some of those things we’ve been hearing for years and are based on long distant versions of PHP (I don’t know why everyone is still so focused on PHP 4, I mean seriously?). Other things are simply baseless and untrue. This isn’t a “my language is better than your language” rant, and I honest believe that every programming language has a purpose. The people who bring these things into the world (who are all a lot clever than me) generally do so for good reason. Programming languages usually don’t happen by mistake.

The answer is simple: because it was there. I’m self-taught, and I don’t have much in the way of formal training. Except maybe for the occasional online course I’ve taken, I have no piece of paper with a stamp on it from a prestigious university that says I can tell computers what to do.

I come from a design background, and although I’ve been tinkering with computers and code since I was like 7 years old, I didn’t follow that passion in education. I’m not even sure why. I like computers, and I like the internet, but instead… I chose graphic design. I’m not going to go into all that because, although I have a degree, it doesn’t really play much part in what I do today.

I came to PHP like I believe most PHP programmers do. Because we wanted a way to make a website do more than display a picture and a paragraph of text. I was so excited when I figured how to get stuff out of a database and display it on a web page. It was mind blowing! This was exactly what I needed and I dove in head first.

Then, I found WordPress. And like every other whippersnapper in front of a computer screen with some basic PHP knowledge, WordPress changed everything. This was cool, right?

WordPress owes it’s success to people like me. All us young kids that wanted a blog but didn’t have the knowledge to build them ourselves.

You installed WordPress… Then you added a plugin, and you changed the theme... Then you made a small change to the theme so it did something else, or looked a little different. Then you modified a plugin. Then you made your own theme. Then you thought to yourself… What else can I do?

And so I was introduced to PHP. I didn’t choose PHP, it chose me. 20 years later, and I’m still building things in PHP. Sure, not really with WordPress anymore, and I like to think I’ve matured as a PHP programmer to know how to write this post.

One of the big reasons PHP is so popular is because it’s so ubiquitous. It’s installed almost everywhere. Hell, even your average MacBook comes with PHP pre-installed (although that looks like it will be changing in a future version of MacOS).

It’s also really easy to write PHP from the word go. You usually don’t need to do anything special. Create an index.php file and put a single line of PHP in it and upload it to pretty much any shared hosting account:

<?php
echo 'Hello, World!';

And you’re done. Starting out with PHP is really easy because you really don’t need to also know how to make PHP work. It’s almost always already been done for you.

However, if you can believe it, this “ease of use” is actually one of the complaints about PHP. The theory goes that if PHP is so easy, then it’s also really easy to write really dangerous code in PHP.

I’ve always felt a little uneasy about this idea. Is the suggestion then that languages which are harder to use are less likely to be used to create bad code? I read somewhere that something like 70% of the patches that Microsoft release for Windows are to address memory problems introduced because of C++ (don’t quote me on that though). I doubt that the people who write C++ for Microsoft are amateurs, and I’m pretty sure they know what they’re doing. Yes, Windows is far more complex than your average shopping cart website, but I think the argument stands. I disagree that PHP being easy to to use is what makes it dangerous. Python is highly regarded as beginner friendly, yet doesn’t get the same “dangerous” reputation. It’s easy to write dangerous code in ANY language. It’s not the language that makes code dangerous, it’s the lack of knowledge.

“Easy” is not a reason to discourage beginners from learning PHP, but rather, a reason to give those beginners better tools to make better decisions about the code they write. It’s a reason to help them find the right resources to learn PHP correctly. I was pretty lucky; and although I’ve written my fair share of “dangerous” code, there have been some well placed individuals in my life (not always PHP programmers) that have helped me figure out where to improve.

Well, that’s not true. PHP is as fast or as slow as the code you write. PHP is a scripting language, so it’s pointless to compare it to compiled languages, yet for some reason I’ve even seen people compare PHP with Rust, or Go. Those are just not going to be valuable comparisons. Comparing it to Python or Ruby is probably better, but the “speed” of a language is dependent on a number of different factors. The language itself, yes, but also it’s environment, what code it’s running, how the interpreter is configured, etc. To say that PHP is slow without context is disingenuous.

PHP is definitely slow with regards to certain types of tasks. For example, PHP probably isn’t your first choice if you’re working in the machine learning space (although there are some very interesting projects that are showing some promise).

Sometimes, you’ll see benchmarks between two different languages doing the same thing, like looping over a million records and doing some simple calculation. The results are often milliseconds apart. This is sometimes used to show that PHP is slow (or fast, in some cases). If you are writing software where an extra few milliseconds when looping through a million records would be disastrous, then maybe you’re asking the wrong questions.

Yeah, I kinda agree. I’m not a the biggest fan of WordPress these days, but I’m also willing to admit that without WordPress we probably wouldn’t have the kind of PHP community we have today.

However, it’s also bad to judge a language because of one piece of software. That’s like saying C++ is a bad language because you don’t like Microsoft Windows.

PHP is not a one trick pony and WordPress is only one side of the PHP story. There are plenty of frameworks and packages to choose from if that’s the way you’d like to go. Laravel has been credited with “making PHP cool again”, and I have to admit that the framework is by far one of my favourites and an easy choice for me for most projects.

Blaming PHP for the misgivings of WordPress really isn’t fair. It could be argued that WordPress was a reflection of the limitations of PHP, but that was a long time ago, and the language has matured extensively since then.

Why? I really don’t get where this comes from. But it’s a big one. What makes a language “enterprise ready”? How is one language more enterprise ready than another? Java is probably one of the most popular languages in the enterprise space, but it’s not because Java itself is enterprise ready. It’s because of the existance of the Java EE Platform. I’m no Java developer, so I stand to be corrected here, but from what I understand, Java EE is a platform on which enterprise applications are built. Sounds kinda like a framework, right? So maybe the question should be “is <my-favourite-php-framework> enterprise ready?”

The answer to that question is for a different post entirely. The point I’m trying to make is that PHP as a language is as much “enterprise ready” as any other language. It depends entirely on how you use it.

Just a side note, some time ago I was a part of a small team which built and deployed an events management platform onto the internal network of one of South Africa’s foremost financial institutions (I might write something about my experiences with that). The app was written entirely in PHP and JavaScript. And with the Covid-19 pandemic in full swing, the system was under extreme pressure, yet it has handled almost all of it. We’ve had a few hiccups, but nothing that couldn’t solved quickly.

This is the only one that has maybe a thread of truth to it, but it’s more complicated than you think. In truth, PHP is able scale just fine, if you write decent code. When people say that PHP doesn’t scale they usually referring to the idea that applications written in PHP might not be able to handle very large numbers of requests (like in the millions). The thing is that it’s still not that simple and I think a lot of the misconception comes from WordPress, which, until recently was well known for having scalability issues.

As a bit of proof, Slack, the messaging platform that tried to replace email, has milllions of users, all of whom connect every single day to a system who’s backend is written in PHP. If that’s not a story of how PHP can scale, then I don’t know what is. Many people cite Facebook as a good example, and although I believe Facebook probably still uses PHP in some form, I think they’ve probably moved much of their application away from PHP. But, to be honest, Facebook is a bit of a special case.

You can’t talk about scalability without also talking about infrastructure. If you’re hosting a WordPress blog on a simple shared hosting and you suddenly get tens of thousands of hits… well that could likely be a problem and your host is going to send you a nasty email, or at least bill you a lot more than you were expecting.

Scaling an application involves a lot more than just your language choice. There’s a lot of moving parts and I get frustrated when PHP takes the brunt of the blame. Newer versions of PHP, in the right environment and configured correctly, are more than capable of dealing with a large number of requests per second. Laravel Vapor, which is a first-party serverless platform for Laravel applications running on AWS, has some really impressive numbers.

I sometimes think the question of scalability is also a bit of an over exaggeration. In my 20 years of writing things in PHP, I have never had to deal with “millions of requests” per second. Not even close. The majority of us are not going to be building the next Facebook, no matter how much we like to dream about doing just that. In reality we build apps that are far more targeted. We deal with specific industries, often in specific countries and we never have to worry about dealing with more than a few hundred requests per second. For many of the projects we’re involved in, that would be large. It doesn’t mean that what we do isn’t important, it just means we don’t need to think about that sort of scale. Scaling applications to deal with millions of requests just isn’t a part of our normal day-to-day.

You have to be kidding me. I’ve saved the most irritating for last. If you are selecting your tech stack based on how nice it looks, then you’re doing it wrong and you need to seriously re-evaluate your choices.

But even still, I don’t really think it’s true. It probably comes from the age old practise of using PHP directly in HTML (whish is ugly). The thing is: we really don’t do that anymore. In fact, it’s seriously frowned upon.

I’m not saying that so called “beautiful languages” are bad choices, but it definitely should not be your determining factor. Java is downright ugly, yet is one of the world most popular languages. Arguing against the use of PHP because it is ugly is just silly.

PHP probably isn’t the most beautiful language, but I find it’s quite readable when well written. And PHP 8 brings some really great tools to help make your code even more “beautiful”.

I really do. I love the language and the ecosystem. I love how it’s been improving over the last few years. PHP 8 is not just another iteration of the same language. With each major release we get better and more useful tools.

I love that PHP is easy to get started with, but I also love that it’s complex and there’s actually so much to know to be considered a professional PHP programmer. I love Symfony and Laravel and think that people behind them are as much responsible for pushing the language forward as the PHP core team is.

But mostly I love being a programmer. Not just in PHP, but I love creating stuff in any language that I happen to use. I love the fact that I can tell computers what to do and that I taught myself how to do that. I owe that to PHP. Without PHP, I don’t know what I’d be doing now. Maybe I’d be some mediocre designer hating my job and my life (no offence to any designers reading this. I have really talented designer friends who also love what they do). But instead I get to do something I love to do, using a language I love to use.

The end.

The Startup

Medium's largest active publication, followed by +755K people. Follow to join our community.

Medium is an open platform where 170 million readers come to find insightful and dynamic thinking. Here, expert and undiscovered voices alike dive into the heart of any topic and bring new ideas to the surface. Learn more

Follow the writers, publications, and topics that matter to you, and you’ll see them on your homepage and in your inbox. Explore

If you have a story to tell, knowledge to share, or a perspective to offer — welcome home. It’s easy and free to post your thinking on any topic. Write on Medium

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store