DEV Community

Cover image for Why developers hate PHP

Why developers hate PHP

Mehdi Zed on January 08, 2021

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 i...
Collapse
 
markrailton profile image
Mark Railton

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.

Collapse
 
andreidascalu profile image
Andrei Dascalu • Edited

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.

Collapse
 
thinsoldier profile image
thinsoldier

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.

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

Sure, myself included.
Things evolve.

Collapse
 
verystrongfingers profile image
Mitchell

it's a pain in k8s to consider always a webserver sidecar that needs access to the same files

it's worth noting nginx-ingress now has FCGI support, you can get away with one deployment & an ingress nowadays :)

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

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.

Thread Thread
 
verystrongfingers profile image
Mitchell

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

Collapse
 
jcarlosweb profile image
Carlos Campos • Edited

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...

Thread Thread
 
jcarlosweb profile image
Carlos Campos • Edited

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

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

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.

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

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).

Thread Thread
 
jcarlosweb profile image
Carlos Campos • Edited

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.

Thread Thread
 
andreidascalu profile image
Andrei Dascalu

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.

Thread Thread
 
jcarlosweb profile image
Carlos Campos • Edited

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.

Thread Thread
 
jcarlosweb profile image
Carlos Campos • Edited

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.

Collapse
 
nataliedeweerd profile image
𝐍𝐚𝐭𝐚𝐥𝐢𝐞 𝐝𝐞 𝐖𝐞𝐞𝐫𝐝

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.

Thank you!

Collapse
 
andreidascalu profile image
Andrei Dascalu

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.

Collapse
 
pbose profile image
pBose

Evaluation of PHP

Alt Text
Alt Text

And people hate PHP but love Laravel
Funny...

Collapse
 
rvxlab profile image
RVxLab

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.

Collapse
 
pbose profile image
pBose

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.

Collapse
 
syntaxseed profile image
SyntaxSeed (Sherri W) • Edited

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.

Collapse
 
_hs_ profile image
HS

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

Collapse
 
bglamadrid profile image
Benjamin La Madrid

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.

Collapse
 
pjmantoss profile image
PJ Mantoss

Nice one Zed. Never understood why devs hated PHP. Now I know. And I also like your sense of humour. It's refreshing.

Collapse
 
calag4n profile image
calag4n • Edited

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.

Collapse
 
andreidascalu profile image
Andrei Dascalu

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:

  1. developers stuck on old versions and prevented from evolving alongside the language by their projects (thinking of WP developers mostly, though I'm sure there are plenty of legacy projects in maintenance). There's some ripple effect here because developers stuck with antiquated practices and versions tend to stick to bad (and old) practices they need to unlearn later. This brings a different kind of hate that affects the image of the language.
  2. lazy people who can't get themselves to learn something else. You don't like it, get a grip and learn something else. Nobody's forcing anybody to get a mental breakdown.

Otherwise, yeah, PHP is plenty bad:

  1. language inconsistencies - they tend to get solved, PHP > 7.2 is great and > 8 can actually stand alongside any language but it's hard to argue evolution when plenty of old versions are in use and plenty of developers are rooted into those.
  2. it's bad for microservices (deployment wise, but also performance wise) due to being dependent on external tooling (eg: third-party webserver like nginx or apache or others). It's a headache to make an efficient small microservice under Kubernetes with PHP.
  3. Wordpress - yes, it powers a lot of current internet which means it can't evolve even when PHP does. While wordpress supports new php versions, its API won't support new language features, making any WP custom codebase even messier than it already is (you can, by any means, use new language features - but consider a developer working on a WP module -> they will take cues from existing codebase).

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?)

Collapse
 
thinsoldier profile image
thinsoldier

Could you point me to a good tutorial in any language on how to maximize search engine friendliness when not rendering content server side?

Collapse
 
andreidascalu profile image
Andrei Dascalu

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.

Collapse
 
Sloan, the sloth mascot
Comment deleted
Collapse
 
joshuaamaju profile image
Joshua Amaju

What are you even talking about....

Collapse
 
kurisutofu profile image
kurisutofu

I admit I have a bad impression of PHP but that's because the last time I really used it, it was PHP4 ... I think my reluctance to touch it again is not really based on thinking it stagnated like said in the article but more because I found it so bad at the time that I think it's like PTSD ... just thinking of using it, I'm sweating, lol.
I'm pretty sure I will try it again someday but there are so many languages and technologies to try in programming that now, finding free time is the issue ...

Collapse
 
ajayyadav profile image
Ajay Yadav

If you hate any language just because "James" hates a lot 🤣 it means you have some serious issues. Dude, you can hate php at the same time you can see statistics of its progress from php 4.0 to 8.0 and php has evolved a lot. That's why it is one of the most important language in the field of web development. It's really so easy to pick up and start developing websites using php.

Without frameworks and libraries of any language does not look good like node and ruby... Same with php also.

PHP welcomes JavaScript in frontend and works together

php does not hate to any language but other languages hate php...

PHP doesn't care you hate or love it, you can't imagine web without php, open your eyes only than you can see that 80% websites are in php in 2021.... And its continue

Collapse
 
mikequade profile image
Mike Quade

Thanks for the article! After putting my gun down, I really enjoyed reading it.

My point is that PHP is old but I see it as an advantage. Older languages are not changing their language features all the time. The documentation is good, examples are available everywhere and it has a huge community to ask if you are stuck.

There are also lots of articles and best practices available regarding security. Or about how to write good code which imho relies on the dev's skills, effort and responsibility (maybe even a little bit of empathy) and not on the language itself.

With newer languages, I've already spent hours on finding code examples that actually work because half of stack overflow post examples are already deprecated or even the official doc might be deprecated.

That beats the bad code argument for me because newer languages might be safer and more restricted, but if there is no information or actual doc available about how it is supposed to be used, you'll end up hacking your code together again without really knowing what you are doing.

It might not be that easy as in PHP, but it can still cause a lot of trouble later and security leaks.

 
andreidascalu profile image
Andrei Dascalu • Edited

Sure, so the conclusion is that php is OK when not using kubernetes and when that's the only thing developers know.

Which is exactly the reaction I get from pure php developers. Yeah, kubernetes is difficult when trying do to anything with php because it is difficult (and in efficient) to do php under kubernetes (again, unless using roadrunner).

You don't need kubernetes, sure. Unless you need a way to autoscale quickly on demand, since it's faster to scale containers than vms (as you would in EBS). Which is something everyone ends up needing for any scale APIs, which is why I end up migrating php to golang as a full job :)

 
andreidascalu profile image
Andrei Dascalu

It's capable, I didn't say it's not. But assuming you have a team that also works with, say, elixir (or rust, go, node) - what would be the characteristic of the language that makes it more suitable?

It has detrimental stuff: its internal webserver is too poor for production and needs an external one, so container deployment with orchestration becomes painful. You can choose a high concurrency platform like Roadrunner, but only if you make your application fully PSR compatible and I still run into devs that haven't heard of PSR. This also disqualifies Laravel (poor compatibility with RR and poor performance) as well as Lumen (no idea what's the connection to Laravel since the core is not compatible)

 
andreidascalu profile image
Andrei Dascalu

It is a factor when deploying orchestrated containers. In k8s for example, it's terribly in efficient to have nginx + php as separate containers with access to the same files. The request path goes like: external load balancer -> ingress controller -> local nginx -> fpm. There's an extra webserver in front which none of the other platforms need which only adds to latency.
The result is that on k8s, node + a fast router like fastify is roughly 3x times faster than your basic php rest api with Symfony. Although, if you switch to php + roadrunner in the same containerized context, php and roadrunner is roughly 2x faster.

Collapse
 
btlm profile image
btlm

PHP is very easy to learn and almost like "plug&play" - write a script, upload it to a shared FTP server and it works. Due that there are many wannabe developers who claim they are PHP developers because they wrote few webpages or even single scripts.

At my former workplace, we had many applicants who couldn't even connect with the database (but they judged their PHP knowledge as 4/5 or 5/5 in the CV).

I like PHP as it was my first language learned and I've been using it for long years and I don't understand the hate, excluding a reason given above. But it is a problem with people, not the language itself.

Collapse
 
mukhammadsobirov profile image
Mukhammad Sobirov

I can't understand why would someone "love" or "hate" certain programming languages.
They're just tools that can be used to achieve certain goals.

Collapse
 
bartosz profile image
Bartosz Wójcik

PHP is awesome, it's highly productive and with modern frameworks like Yii2 and Laravel you can build miracles within days. Plenty of packages, great documentation, tons of examples and a community that will help.

Collapse
 
elmuerte profile image
Michiel Hendriks

I've invested a lot of development time in PHP from 1999 to 2009 (at least), and I hate it.
It is not just the inconsistency in the runtime. It is not just the horrible language design. It is not just the incredible unreliable stability (although Node is seriously challenging PHP on this one). It is for a better part the continuation of these atrocities.
There is only 1 good thing about PHP, and that's how easy it is to enable in Apache HTTPd.

Collapse
 
m4rcoperuano profile image
Marco Ledesma

Love your post. My experiences with many languages made me realize that it’s not necessarily the language that I dislike, it’s the context that it’s in. For example, I dislike PHP when it’s in Wordpress, but love it when I’m in Laravel.

I dislike c# when it’s in old MVC Microsoft frameworks, or even webforms (ew). But love it when it’s in dot net core.

I wonder if this is what most developers mean when they say they hate X language. Is it really the language? Or the context that you’re developing with the language? Maybe it’s a little of both. Idk. My 2 cents :)

Collapse
 
ihorvorotnov profile image
Ihor Vorotnov

Haters: PHP is BAD, PHP is DEAD!
PHP Developers:

Money

Collapse
 
ironcladdev profile image
Conner Ow

Oh man, you used the best memes ever LOL!

Collapse
 
isvander profile image
Isvander

i do hate php because of lack of features, but php 7 change my minds

Collapse
 
realtoughcandy profile image
RealToughCandy.io

PHP definitely leaves people... opinionated. Good read, fun memes.

Collapse
 
vikkio88 profile image
Vincenzo

thanks for this, as a guy who now works mostly on node/typescript, I miss a nicely written php codebase.

Collapse
 
andrewbaisden profile image
Andrew Baisden

When people think of PHP they immediately have thoughts about WordPress and it triggers bad memories that they might have had in the past with that experience.

Collapse
 
ivan_jrmc profile image
Ivan Jeremic

JavaScript is the most widely used not PHP

Collapse
 
qaniel profile image
qaniel

its simple, cuz most devs have never touched JS... thats why php gets all the hate