PHP is the most widely used language in the world for websites. It is also the most hated. And it's pure hate. But why do so many developers hate it so much? Today we're going to the origin of the hate, let's see if it's really justified.
Don't touch my PHP
If I'm saying that PHP is hated by the whole world, it's not my personal opinion. In the latest stack overflow survey, developers from all over the world put PHP in the top 5 most dreaded languages. The latest Hired survey puts it squarely in the top 2 most hated. There's a lot more and I'm not even talking about what's going on Reddit. If you're a PHP developer since 20 years who came here on a crusade to crucify me on the altar of Symfony, please relax. We're here to talk, put the gun down. Well now on the contrary if you hate PHP with passion : take some pop-corns and sit down comfortably.
Once upon a time I was doing some Symfony2 myself. And I liked the whole Symfony thing, frankly, it's not bad. I told this to a developer I met at a devops meetup. He was shocked, he was about to vomit, he looked at me like I just murdered a newborn baby. From now on I'm going to call him James to make it easier. So I immediately asked James a question: why so much hatred?
PHP trouble past
To understand what's coming next, you need context. In order to do that, let's make a little rewind. It's 1994 and Rasmus Lerdorf is quickly coding a C tool suite. This suite of tools is used to manage his personal website. Rasmus is doing it just for his own need at the time. He doesn't want to turn it into a programming language. Nothing in this tool suite is designed to become one. A year later Rasmus released this open source toolkit called then: PHP/FI. And it looked like this.
<!--include /text/header.html-->
<!--getenv HTTP\_USER\_AGENT-->
<!--ifsubstr $exec\_result Mozilla-->
Hey, you are using Netscape!<p>
<!--endif-->
<!--sql database select \* from table where user='$username'-->
<!--ifless $numentries 1-->
Sorry, that record does not exist<p>
<!--endif exit-->
Welcome <!--$user-->!<p>
You have <!--$index:0--> credits left in your account.<p>
<!--include /text/footer.html-->
We're far from what you're using today in your huge PHP7 framework, aren't we? Yet it all comes from there. For the rest of the story : the code is taken over by a dev team and PHP/FI2 is released in 1997. In 1998 a part is rewritten and PHP3 is released. In 1999 the core of PHP is totally rewritten to produce Zend. PHP4 follows the next year and PHP5 is released in 2004 with Zend2. PHP6 got canceled because the development has turned into hell on earth. Finally, through yet another major rewrite of the language: PHP7 is released in 2015. I remember at the time I was very excited. But originally, Rasmus was just coding his own thing . In 2003 he did an interview and told some incredible things.
"I really don't like programming. I built this tool to program less so that I could simply reuse code … I don't know how to stop it, there was never any intention to write a programming language […]. I don't know how to write a programming language at all, I just kept adding the next logical step."
Inconsistency and poor design
Back in 2019 with our friend James from the meetup. He immediately started talking to me about the "disgusting" syntax of PHP. How the language is not typed. How the language is mostly unpredictable. Whether it's on the use of operators or the incredible inconsistencies in function naming. I'll spare you the list of technical problems because otherwise this article will take you all day to read.
If you really want to know everything I found you the most pissed off person in the world against PHP. No, actually I think the person who hates PHP the most is actually him. All those posts validate what James was telling me. Developers hate PHP because it's a technically inconsistent language with a bad design. When you compare it to other languages the contrast is obvious. If after reading these two articles you can't admit that PHP have some problems it's because it became your religion. And I stopped trying to convince fanatics.
Using PHP it's very easy to produce bad code. Other languages have many more restrictions. We also see a lot of security problems with PHP. And the problem is the same here. It's very easy to make bad and insecure code with PHP. But PHP is not a security hole or doomed to ugly code if you code properly. Developers hate PHP because you are more likely to get errors with a language that allows so much freedom.
Victim of its success
There is another important factor in this ambient hatred. Developers hate PHP because it is used everywhere. This blog runs on PHP7. Like most of the web I just need to host a dynamic page which is then cached. PHP does the job. Yes the language itself is not the best. Yes i could use a super duper stack. But who cares ? It meets my needs in a fast and accessible way. It's also for this reason that 80% of the web runs in PHP.
When I explained the same thing to James he started to go crazy. Like you and me, James have friends and family. These people frequently ask him for help with their professional and personal websites. Guess what language always comes up on these people's websites? So James finds himself having to change things in PHP often. And he gets incredible headache from it.
With the advent of WordPress, which literally dominates the Internet, James will play with PHP for a long time. By the way, I'm talking to you as if this language could only handle a blog like mine but that's obviously not the case. Facebook, Wikipedia, Yahoo, Flickr, Tumblr all these sites run in PHP and welcome millions of users every month without flinching. PHP does this very well and has been doing it for a long time.
The future is now old man
You've been hearing for 10 years that PHP is going to die. Yet he's still here. Despite time and the latest hypothetical technology, it's not moving. Developers hate PHP because it is the opposite of hype driven development. In a profession where everyone invests quickly on the latest stuff, PHP is an old man who doesn't want to sell his land. An old man who continues to dance insolently.
My discussion with James continues normally and all of a sudden he tells me something completely shocking. "On top of that PHP is by far the slowest language you can find for web". When he said that I understood that James didn't read anything on PHP since a long time.
PHP evolves, not its reputation
In the minds of many developers, PHP has remained in version 4. When the language was unstable, with disastrous performance and non-existent OOP. Developers hate PHP because they believe the language has been stagnating for 20 years. When you know PHP today you know that it's far from PHP4.
PHP7 is faster than Python and Ruby. The language can be strongly typed if you wish. Tooling is also evolving with static parsers that have appeared in recent years. Frameworks like Symfony or Zend force good practices. A new version is released every year with a very precise agenda. Moreover PHP7.4 is here with even more performance. Once again I won't list everything that is happening in modern PHP for the sake of length. If you want to know everything I invite you to read this article. It's time to change your vision on this language that has nothing to do with what it used to be.
Developers hate PHP because it's cool to hate PHP. This language continues to have a really bad reputation because of it. And yes, there is a strong legacy and a lot of problems. But there is a lot of good stuff too for most of the websites.
Epilogue
Most developers who hate PHP hate it out of elitism or ignorance. Either way it's dumb. You have to choose a technology based on what you need. PHP is highly useful and powerful in many scenarios. And taking it out of the equation just because of its reputation is not a good idea.
Top comments (50)
As a developer that uses primarily PHP for the last 7 years I’ve heard all the hate before. I even stayed out of the Python community in Ireland after one of the Python Dublin group orgs belittled me for using it.
However, I personally find modern PHP a joy to work with and hey, it puts food on my table.
You really hit the nail on the head, people hate on PHP because it’s cool to hate on PHP and most of those most likely haven’t written a line of PHP in over 10 years and have no idea how much the language and ecosystem has improved. But hey, haters gonna hate.
Wrote a reply on a similar post a while ago. The gist would be that the fact that php has improved is irrelevant.
There's too much legacy out there that keeps churning out developers with bad habits.
Also php is particularly ill suited for modern patterns like microservices (somehow php is still unable to come with a webserver, it's a pain in k8s to consider always a webserver sidecar that needs access to the same files - fortunately nowadays there's roadrunner and symfony supports it). It's not hate deserving but I can't think of any situation where php would be my first choice if I had options.
Every former PHP coder I know would never have become a coder if not for starting with PHP. Not so much true these days since JS is popular everywhere (in spite of being as bad and as old as PHP) and is even easier to get started with.
Sure, myself included.
Things evolve.
it's worth noting nginx-ingress now has FCGI support, you can get away with one deployment & an ingress nowadays :)
Ah, the promised land is here! I will try it though at a glance this helps as long as you’re using a proper framework/router with a single entry point.
there's annotations to cover rewrite rules as well
kubernetes.github.io/ingress-nginx... which would be appropriate for a non-router based app.
I haven't tried it myself yet, but it nginx-ingress now seems viable enough to replace the sidecar/pod reverse-proxy for PHP deployments
You are talking about high traffic pages, lucky you. I have 100 pages published with Symfony and I have never needed kubernetes, I hope one day I will need it. And I found that the problem is Nginx + FPM .
By the way, once I tried to find a framework that looked minimally like Symfony in Go, and it was impossible. There is no such quality.
I suppose that PHP community is better than Node.js/Go community, I don't say Javascript because there is such a big community because there is no choice but to make Frontend in any kind of Web. But node.js is awful, you start to play first hand and you find that you can't even launch a JSON natively.
Here is more reference about the speed of PHP
techempower.com/benchmarks/#sectio...
And now I ask you a question, you tell me that with just Node.js + Fastify, you don't need either Nginx or PM2? Why don't you mention it. I've used Node.js, and I needed all that. I guess I did it all wrong
on k8s, you don't need another nginx beside the ingress controller. The problem is that when you need to put something in front, for PHP, it MUST know about the files that PHP needs to interpret.
With Fastify, it's best practice to put something in front that has better scaling - but it can be anything. You can put Ambassador or Haproxy or whatever. With PHP, you can't - it must be a webserver (that knows about files & document root). With an orchestrated environment (like k8s or compose, depending on practice), just using a load balancer (or ingress controller) is not enough, you will always need an extra webserver that sits with the code.
Well, if you look for frameworks that look like Symfony .... there's only Symfony. Not sure what you mean by "like Symfony"? Full MVC? Service layered? Bloated? Tightly coupled?
What fits in PHP won't fit in other languages.
In Go you will never find something like that because the Symfony model simply doesn't work in a high performance environment built around concurrency and parallelism. Almost. You can use the minimal Symfony framework (technically configuration + router + DI) with RR (for concurrency .... with ironically is written in Go) but if you do that (eg: forget the MVC) then you definitely have counterparts. In Node that's fastify and in Go that's fiber. Well, almost, since in Go the DI bit doesn't exist as such.
Thanks for the speedtest reference. It's mostly what I'd expect, although I'm shocked that Spiral (35k) is so low in the list. Also, it's nice to see the raw power of PHP on bare-metal, that's about what you'd expect as well, but I have never imagined that you can get 356k responses with PHP/Nginx/PGSql and just 7k with Symfony/FPM/Nginx/mySQL (well .... I won't be surprised that Laravel is at 5.5k in these conditions).
It's just that we're talking about completely different things and I don't want you to confuse anyone. I think it's very good what you're saying. But I repeat again what you are talking about is a big project, not a simple one, as I have told you before, along my career I have published 100 web pages, some with more and less traffic and I have never needed to Kubernetes and direct everything to microservices, I am learning that now? Well yes, that I need it? No, right now. And it is possible that I don't even need it. Maybe if I make a web application that has 1 million visits a day, then I'll separate it into microservices and I'm sure I'll remember you. hahaha.
Currently I find Symfony incredible. There is nothing like it. In Node.js, I found something similar and it's not called Fastify, it's called tsed.io/docs/controllers.html, but of course but as I said before is that unfortunately I'm not at your level or I work in such big projects.... And I think most of them are not either. I hope and desire some day to pass for that, I wish Go had made it more modern, it is a new language and I don't like it. More similar to Typescript or PHP8 would have succeeded.
Well, yes and no. The OP was an academic question. Why PHP gets hate. There are plenty of reasons.
Does that mean PHP is a bad tool? Not at all. It's not the best, regardless of use case, there will always be something better.
But nobody's trying to convince people to change what they use. For any given participant here it's true that whatever they use now is good enough, otherwise they would be looking for a change.
Like you say, you'd need a use case to consider a change. 80% of people are like that. Then there are people that don't need to learn under pressure and are just curious.
Kubernetes has nothing to do with high traffic. It helps but it's not the only use case. In our company we use it to keep experimentation costs down. There are a bunch of VMs in a cluster and if you are a dev all you need to do to get your app public is to describe it in a Dockerfile and push it to a repo. In a few minutes you can automagically access it through the cluster ingress. Cluster size goes up and down automatically. It's not under heavy traffic but it makes deployment a breeze, regardless of language.
But on the language subject, it also matters what you want to use. People use Typescript but that doesn't make it good. While I'm OK with PHP and will probably always use it in some capacity, I acknowledge there are better things out there. But Typescript is crap, even though it was necessary when it came out. Nowadays Reason is way superior (and was created by the React guys for React) and hopefully will get traction.
There's plenty of great things out there as long as you can get out of the bubble. Symfony has crappy performance but run it under swoole or roadrunner and you have something (look at the benchmarks you provided). Often it's not even about changing tools just about using them slightly differently.
Yes, Symfony is not king, but I love it for what I need. And yes! Swoole and Workerman is faster than Fastify and Symfony
And as I say you are right, in almost everything. But it's not my use of case, or you don't know that there are shit websites made in Wordpress with more traffic than any other microservice-oriented page(10 people programmed microservices in different languages) .
Example: css-tricks.com/
Hey, but I don't defend Wordpress, it's fucking bullshit. But as I say, it depends on the case.
Edit:
Also, thank you very much for all the information, I hope one day to work with Kubernetes and oriented microservices, and I hope never to leave aside PHP, And of course that Symfony becomes something faster comparable to Wokerman or Swoole, so that I do not have to learn more things.
Actually php is useful in exactly one scenario: I have developers that only know php. Php was useful when people were doing MVC monoliths. Nowadays people turn to spa and fast microservices. I can't think of a scenario where I would choose php off the bat when given a choice of backend platforms. I worked in php for 18 years now and for the past 5 I've mostly migrated php monoliths to (micro)services in one of go,node,rust or elixir.
Evaluation of PHP
And people hate PHP but love Laravel
Funny...
I primarily develop using Laravel, I love using it as I do PHP but oh man do I have some things to say about the sheer amount of magic it uses.
It makes debugging a gigantic pain in my rear sometimes.
However, this is a trade I’m willing to make because of its ecosystem and the speed I can build stuff in it.
Definitely, I am also working on laravel from past 4yr, But before learning laravel's each release I love to study PHP first, otherwise I would never understand how and why laravel having those magics.
Oh look... another trend-hopping post that adds to the dogpile by finding ancient articles and joke memes to snag the low-hanging fruit and get attention by once again claiming PHP is terrible. But wait - it's redeemed at the end right? These posts do more harm than good and perpetuate an expired belief that has zero applicability to modern PHP.
If the writer actually does use and enjoy PHP today, it doesn't come through in this article - I apologize if I misread this.
PHP had an enormous pool of beginner developers years ago, who wrote terrible code - as we all do as beginners - then moved to another language and their opinion of PHP remains stuck on the terrible code and the messy state of the language all those years ago.
Every tool in a swiss army knife is worse than if you bought a specialized tool... and yet how useful and awesome is a multi-tool? PHP has evolved to be the best muti-tool out there, losing most of the things that gained it criticism in the past. The only thing PHP still hasn't solved is the outdated opinions and the trendy dog-piling that developers who want something to write about keep clinging to.
Personally, for those of us who work in, promote, support, and earn a living with PHP, reading these types of articles over and over and over is tiresome and pretty offensive. Like if you worked hard to save up and bought a new car and all your friends ever talked about is how crummy your old car was.
Same thing you can find for other languages... Java. I do dislike PHP because of syntax but that's a matter of taste yet I still accepted a job that does HTML generating on the backend in PHP without any framework so let's see how that goes. But again how many even PHP developers would accept such position? No framework, PHP, and to top it all it's server side rendering hehe. We are to spoiled in one way and too overloaded in another. We are basically at the bottom of the food chain in industry yet we still need to think about security or such. I just wonder how many of them would like other mainly-web (well languages that are used for services that serve either web or others via network) languages if not for frameworks? Reason I love Java is ecosystem. Reason I hate Java is sometimes Java. But I love forcing exception handling and such which others hate. So PHP has similar thing, it's horrible language with great things and it's getting better. But when someone makes you suffer you don't care if they change
PHP may not be as efficient or easy to follow when building big projects, but it's great for prototyping or deploying small ideas fast.
I wrote a RESTful payment microservice for my eCommerce project in under 100 lines using PHP, and thus it's super easy to maintain.
Its CLI also serves well to run a test webserver without any hassle.
Nice one Zed. Never understood why devs hated PHP. Now I know. And I also like your sense of humour. It's refreshing.
I'm sure there are people that hate PHP, but "hate" is a pretty big exaggeration in a world where: a) you can change the tools you use anytime and b) things evolve over time.
The only people who can say truly hate PHP are:
Otherwise, yeah, PHP is plenty bad:
I would take PHP over Python any day, I would take PHP + Roadrunner for some microservices over NodeJS (though this means the only frameworks I'd use are Symfony and Spiral which workd great with RR, while things like Laravel are awful to maintain and have poor performance when compared) but otherwise I don't see a reason to go with PHP if there's a choice (myself I can use one of Go or Elixir ... so why would I choose to start with PHP unless I'm aiming at server-side rendered monolith?)
Could you point me to a good tutorial in any language on how to maximize search engine friendliness when not rendering content server side?
Sure.
snipcart.com/spa-seo
And a great one on Google's playground. codelabs.developers.google.com/cod...
Details of SEO change quite often as various search engines change how they deal with static content (which SPAs technically are). Google is by far the friendliest engine but there are also some other details.
Sure, it's somewhat harder.
But then again server side or not, it's not really related to the PHP discussion.
What are you even talking about....
I learned PHP7 and I didn't like its syntax so I went learning Express and Django (I love this one). No hate but I avoid it.
Also, I had to dive into Wordpress and my head almost explodes 😆 (2 years ago).
Indeed, the world is full of PHP and it's a good point for you guys who like to work with.
Some comments may only be visible to logged-in visitors. Sign in to view all comments.