r/webdev • • 29d ago

Question How warranted is the PHP hate?

I feel like there has been a lot of hate on PHP, especially after the recent blowout regarding PHP vulnerabilities that even ended up on mainstream media. I even saw absolute non-techy people bringing up PHP and talking authoritatively about how "bad" and "old" it was lol. Not to mention the AI-shills saying one should just use Claude to create one owns CMS (!!). I am also aware that most PHP hate is usually misaligned hate intended for badly managed WordPress sites. And that some people just prefer other languages or love a hatetrain.

But one thing in particular that got to me was someone who mentioned that PHP has a page with vulnerabilities listed that go back 20 years and have yet to be patched. And that if you are a dev who is in any way interested in security within one's projects, you just don't use PHP at all. It was like having only a screen-door for your house with no locks. Do other languages have similar list of unsolved vulnerabilities? What makes them inherently more secure?

I dug around to find information about other popular programming languages and frameworks and it seems like at least right now, many are being found to have vulnerabilities due to AI being used to find them. React had a critical issue about a year ago, and Python earlier this year (although they did not blow up in the press like this).

Anyway, I would like to hear from people who use PHP regularly for work, beyond WordPress and who can maybe compare it to other languages/stacks as well. Please no low-effort replies from people who last used PHP 20 years ago or just don't like it, if possible.

0 Upvotes

89 comments sorted by

View all comments

8

u/crixx93 29d ago edited 29d ago

Modern PHP is fine, not great, but fine. The issue is the older versions, and there're gazillions of websites written in those. That's why those vulns are so critical, up until like 2010, almost everyone developed their web sites using the language, because it was the only game in town. Currently, we are spoiled for choice when it comes to server side programming languages, and as I said at the start, modern PHP isn't bad, but because we built so much stuff with the legacy versions, those still need to be maintained... Or rather, had to. I've been supporting the same PHP 5.6 code base for the last 10 years, and because of these vulnerabilities management finally greenlit the deprecation of it. It's going to be a huge effort, but we have no choice, we have no way to patch the vulnerabilities without upgrading the language version and that would break the entire product, it's cheaper to migrate everything to NodeJS. I imagine many organization are also being forced to expend resources on this, what's scary is that a lot won't do it because they don't have the money or manpower, so a ton of sites will remain vulnerable

8

u/ElCuntIngles 29d ago

I dunno bro. Seems to me that the problem you had was management, not php.

You've been supporting a php5.6 app for ten years, but it went out of support 8 years ago. You had plenty of time to bring it up to date.

And there is a way to "patch the vulnerabilities without upgrading the language version" even on php5.6, for example Ondřej Surý's builds, which were released within 24 hours of the official patched versions (of supported php versions). I had to do this for a php8.1 app that there is "no budget to update", it took five minutes.

I very much doubt that it would be "cheaper to migrate everything to NodeJS". There might be other good reasons to do that, but the php and Node.js paradigms are so totally different that you would have to completely start from scratch. And in my experience, it's cheaper to build in php than Node.js, particularly with a 'batteries included' framework.

And let's not pretend that Node.js is immune to vulnerabilities. Wasn't there a node2shell about the same week as ph2shell? And god knows what lurks in your 500Mb node_modules directory.

If you had to update a ten-years-out-of-date node app you'd have similar massive issues. Wasn't it all CommonJS back then? No built-in promises? No fetch?

1

u/crixx93 29d ago

I work for a cyber security firm, we applied that patch but what everyone sec analyst in the company believes/ fears is that more vulns like this will eventually be found out in the coming months. The PHP code serves like 4% of our product, and its spaghetti written in 2004-2012, so it's pretty nasty. That's why management never listened when we talked about eliminating that tech debt. But now that AI powered hacking tools are a thing, we have no choice but to rewrite it from scratch (getting hacked is completely unacceptable for a cyber security company). NodeJS is like the prime candidate for migration simply because most of my coworkers are JS devs, but we also have some people with Rust and Go knowledge

1

u/pionell 29d ago

Rewriting now is 100x cheaper then it used to be. Write e2e tests with claude, then rewrite codebase with new language of your choice.

2

u/pineappletinis 29d ago

Thank you for this explanation. I was going to ask why not just update the PHP version, but you answered the question. That would entail rewriting the entire codebase which is unfeasible. The thing is, with NodeJS, doesn’t that come with having to juggle countless npm-packages which comes with its own risk? Especially since some of them are just maintained by like one open-source dev? Not trying to hate, just confused and trying to understand.

1

u/crixx93 29d ago

It's not set in stone yet. NodeJS is the favorite, but Go and Rust are also contenders, we are suppose to decide next week

2

u/BrewThemAll 29d ago

Blame management, not PHP. Running 5.6 at this moment is the companies fault, not the language.