back
104 comments
I don't care what anyone says— I absolutely love PHP.

I automated my home theatre with it as seen here: https://www.youtube.com/watch?v=Cc8K6lg7Ag8

I built a website just for me so I can stream my movie collection anywhere I go, but it also has a button to start playing an automated show in my theatre.

I call it the Phantom. When you start a show, it plays a Dolby ad, a dancing hot dog-style vintage drive-in ad, and several random trailers in the same genre before the feature.

The Phantom PHP code controls the lights, projector, curtain, and sound system.

The lights come up for the credits and the whole room goes to sleep 30 minutes after the presentation.

I've only shared it once here before and someone, I'm guessing a PHP hater, gave it a thumbs down on YouTube.

PHP is extremely powerful in my experience and has been very lucrative in my career.

One of the best things I ever did was learn how to program with it.

Agreed. Ignore the haters. PHP is a silent giant that is hugely under-rated. While it is a perfect fit for the web, it is also an excellent general purpose scripting language for things that can traditional be done with bash.

PS. Sweet home theatre setup!

I've done a bit of PHP and it is not under-rated. Compared to most other languages it is terrible. Nobody is saying that you can't make cool stuff with it.

Try Typescript in your next project.

Thank you! Not ironically— another thumbs down. All some people have to offer this world is negativity. I feel sorry for them.
I also like PHP. It is also an awful language, though, and always has been. Inconsistent parameter ordering, the infamous NULL/0/""/FALSE heffalump trap, object-orientation as an afterthought. Many more. It's OK once you know the language well, but a lot of PHP developers don't.

I have a PHP app written in PHP5.6, for my own use (not exposed on the internet). Naturally it broke when I upgraded to Debian Buster. Upgrading the code would have taken ages; but it took me just a day or so to work out how to get PHP5.6 working on Buster.

I've retired, because I can, and because I prefer not to work if I don't have to. There's a pretty steep learning curve from PHP5 to PHP8; I don't want to do that learning, if it's no longer necessary for my job, and I'm only using it for a private app.

I've not used PHP8 on anything serious, but my impression is that it's a HUGE improvement on PHP5. It's a lot more coherent, a lot faster, and a lot more secure. A lot of what has been dropped was dropped because it was insecure crap - it had to go sooner or later. In the end it was "better late than never".

I think PHP7+ has provided a lot in terms of modernization and focus on the OO paradigm.

For what it's worth, there are a couple of tools out there that should help getting your personal app up and running on PHP7 if you're interested in doing that at some point. Most of the breaking changes I've run into are because deprecated features were removed, which in a lot of cases seemed like strange/wrong syntax to me anyway.

I have a legacy app that can't feasibly be updated past 5.6 because it uses a totally undocumented framework that wasn't built in-house. While I could run one of the tools I mentioned, 99% of the framework code probably never runs so there would be a lot of work done for nothing.

Why did you go with PHP over another language? Do you have comparable experience with other languages to have had legitimate alternative options? Genuine question.

I'm deeply interested in your project as I have a similar goal. I would also like to create my own custom entertainment setup, throwing in commercials/trailers with feature presentations. Do you have a website or place I can reach out to you with questions?

Or for Hacker News readers, if I want to create a similar custom media playlist kind of thing, is it possible to do that with VLC or would I have to write a custom solution?

I've dabbled a bit in C/C++, and even a little Python, but not enough to build something like this.

Maybe one day I'd like to re-write it with everything I've learnt so I can compile it and monetize it.

I've also thought about open sourcing it, but the code is a little rough (messy) as-is and I struggle with what to do.

I know JavaScript and PHP, and PHP just seemed to do everything I needed.

I built a website a long time ago for collaborative music composition. It interacted with command line software and used XMPP to communicate with the server.

That sorta lead to using PHP to control everything in the theatre, plus a lot of the components I bought can be controlled through HTTP commands.

Overall, this was a side-project and I've slowly perfected the timing and the features over the past six years to where I have it pretty feature complete and reliable now.

Everything is timed perfectly, it can handle intermissions, overtures, and exit music. If there's some sort of break down, it shows film melting, shuts off the projector, and brings the lights up... Stuff like that.

As for VLC: This all runs on a Raspberry Pi 4. I originally used VLC but started having trouble with it when I moved from the Odroid XU4 to the Pi, so now it runs on mpv.

Moved to the Pi because I wanted to run Netflix in the theatre easily as well. If the Odroid ran Netflix (and some other small things), I'd prefer it.

I think there is nothing wrong with PHP if you are using it for what it was built for and you aren't pretending it's something it's not.

It's the people saying "PHP is the best language for building web apps in 2021" that are problematic.

No. It's simply not. We have come a long way since then and that view point can only be held out of ignorance.

That isn't to say you can't build awesome stuff in PHP, you can and in your case did.

But to say PHP > Java/C#/Rust/Elixir/etc is just being an edgelord for the sake of it. Language tech improved, PHP didn't come with it. That is fine, C didn't come with it either but it still has it's place.

Right tool right job, PHP can still be the right choice for lots of things if you have experience with it and can use it to make the thing you want.

This dubious 78% statistic has been discussed to death in https://news.ycombinator.com/item?id=28510520.

The submitted title is badly editorialized and leaves out the actual point of the article: only "1% on PHP 8" despite a whopping 78% total, if we take the dubious statistic at face value.

For the record, the submitted title is "78% of the Web Powered by PHP" at the time of this comment.

If you look at the web by urls not weighted by traffic, you’ll come across the unfathomably large swath of autogenerated spam blogs. For every legitimate business in the world there are 100 people trying to ‘make money online’ paying for scripts that register and post spun content on thousands of domains. The long tail of the internet is an absolute wasteland. It’s tech choices should have little bearing on the rest of us.
To be fair [1] 8.0 is less than a year old.

It's also a bit unwise to jump right into a point zero release when you could wait for point one release with more of the bugs ironed out.

8.1 just hit RC4 [2] five days ago. I'd say after the final RC is approved we will start to see an increase in PHP 8 usage. Even more so after Ubuntu 22.04 LTS release.

[1] https://www.php.net/archive/2020.php#2020-11-26-3

[2] https://www.php.net/archive/2021.php#2021-10-14-1

Yes, thank you. The site's methodology disclaimer explains this is the percentage of sites for which they could automatically determine the language in use on the server. Newer web languages don't include a header telling you the language and version in use at all, and if web frameworks add one, security auditors will always make you remove it.

So the real statistic is 78% of websites that are written in a dynamic scripting language, don't get pen-tested, or don't care about security, are written in PHP. That's a very different statistic than 78% of all servers that will respond to an HTTP request.

So 78% by PHP but 77% below PHP version 8. OK
PHP wins because you can write a few lines of code in single file, shit it into an apache folder, and you have a fully functional front and backend of a web app. There is no other web framework / language that is easier to get started with.

I've always had this dream of writing something like "PyHP" which was the same thing, except you put python files into an nginx folder and anything sent to stdout is sent to the browser, but I've never gotten around to it. Would love if someone made this.

They made it a long time ago. It's called CGI [1].

Seriously, there's no inherent PHP advantage so you have to build something new. It is only that Apache package maintainers started shipping a mod_php package that required almost zero configuration to get up and running. Then every other web server followed suit.

On the other hand, alternatives for other languages were either slow (i.e. CGI-based) or harder to configure (e.g. mod_python [2]).

[1] https://docs.python.org/3/library/cgi.html [2] http://modpython.org/

>I've always had this dream of writing something like "PyHP"

Similar here, Something Ruby-PHP. But even PyHP will do for me.

I think the problem is PHP was designed by someone who just want to get shit done and absolutely dreaded programming. Versus programmers who just wanted to create a beautiful programming language.

I was able to do this with erb (ruby templating language) very similarly to php scripts eons ago. It just never caught on to do it that way for other languages because php already had that market sewn up.

This isn't disagreeing with you, just saying that it is this way for cultural rather than technical reasons.

I don't care about the negativity around PHP (often from JS developers, which has its own quirks and pitfalls).

PHP is a language that gets stuff done, and if you're a good PHP developer, you can put together some beautiful code with a language that many people consider ugly.

I'm sticking with PHP for the foreseeable future. As far as my use cases are concerned, it's a brilliant tool for the job.

The first half of my career was heavy PHP and it helped make me into who I am today. I’ve barely touched it in the last 10 years, but the people who give PHP a hard time are largely misguided.

Last time I wrote about this it got some circulation so I’ll repost here.

https://www.brightball.com/articles/no-such-thing-as-real-pr...

PHP 7.4 isn’t even available in Ubuntu 18.04 LTS without a third party repo.

I wish PHP.net could get some support to provide official repos of their own. It would make upgrading easier.

If you want newer software, why not upgrade to Ubuntu 20.04 LTS or even just the latest Ubuntu?
“LTS” means “stuck with obsolete software”.
I absolutely think Ubuntu's update cycle is a big part of why PHP 8 doesn't have a higher adoption rate. The PHP webapps I write are all served by Ubuntu servers (on 20.04 LTS) and there isn't an official PHP 8 package yet. Even if you're running 21.04, PHP 8 still isn't available as an official package. Ubuntu 21.10 was just released and finally shipped PHP 8 packages, and PHP 7.4 support ends in roughly a month. Anyone sticking strictly to LTS releases won't get official PHP 8 support until ~5 months after PHP 7.4 support ends.
PHP is one of the easiest language to install on Apache and later web servers. It is also a no brainer to install software written in PHP on those servers. It is a wonder why other language implementors haven't looked at doing the same thing.
Because it’s out of the language implementors’ hands. Support in Apache, for example, requires Apache to be compiled with certain configuration, so if big Apache distributors don’t compile with support to your language, there’s nothing a language implementor can do to help. It’s like asking why Ruby doesn’t work harder to make itself included by Windows—I’m pretty sure the maintainers wouldn’t object, but they don’t have a say on that anyway.
Using the [1] PHP-FPM is also a popular (preferred?) way of running PHP whilst not relying on an embedded module and being HTTP server agnostic.

[1] https://www.stackscale.com/blog/php-fpm-high-traffic-website...

I usually work with Go, and it seems a lot nicer just to let it listen on a socket perhaps with Nginx in front of it. Having to install a guest application onto a webserver program has always seemed silly to me.
Probably due in large part to WordPress
WordPress is the Excel of Web Development. Especially when people keep building complicated flows with it, for which it was not designed for. OTOH, the UI is known by everyone and is intuitive, so from a users perspective "it just works", and "you can do these advanced stuff if you learn scripting a bit".

Many projects explicitly look for freelance WordPress developers, it's a huge market and I respect it deeply, but I'm glad my career put me in a position where I can totally ignore it.

What does it say about things when about an hour after the article is posted we have two thread discussing the upgrade question that is central to the article, one drawing attention to the limitations of the methodology, and like five evangelizing with words like “I don’t care what the haters think, I love PHP?”

As of writing, at least, no one here is attacking your language.

Security consultant who audits web applications. I’ve achieved many web shells over the years, the majority (80%) were in php. I’ve never seen an exploitable sql injection vector in anything but php.

When I make recommendations, they’re generally level headed somewhere between fix this, fix all instances of this, or just start from scratch. Php often receives the latter, and not purely on its language merits alone - my last php report was 150 pages due to frameworkless insanity resulting in vulnerabilities in almost every facet of the system (I literally got all top 10 owasp in a single app).

I don’t know what it is about php, maybe it’s the low bar to entry or lack of unit tests, but something about the languages just results in vulnerable code.

Since this article is about when to upgrade depending on your language, I'd like to know if there is a place with information about languages/ecosystems by "longevity", which could be time before you have to upgrade your language, time before you have to upgrade your packages, or something like that. Of course this would be a complex measure. For example, having to upgrade the language AND change code would be worse than having to upgrade the language and don't change code. Same thing for dependencies.

For example, Go has strong backwards compatibility guarantees, but the last supported versions is less than a year old (1.16.9). PHP's security support of 7.3 ends in a bit more than a month, for a total of 3 years of support. Node.js is a bit younger but will still have 3 years of support. Java 8 still has extended support until 2030 by Oracle. There are also things like, with PHP, you may just have to change the environment, but with Go, you would have to recompile the code.

Maybe this could be better expressed as a "maintenance cost" or "churn"? I often hear that "ecosystem X has a lot of churn", but often it's not really well justified. For example, frontend JS moves a lot, but backend JS seem to have been "stuck" on Express for quite some time, and Express itself seems stable, if a bit dated. Maybe that's because we only hear about people changing code, frameworks, best practices? I don't see a lot of articles like "my 5 years old codebase is pretty much the same as when I began", compared to "I switched from X to Y".

Not exactly this, but we track EoL dates of almost every mainstream languages along with their release cycles (and compatibility guarantees, if any) at https://endoflife.date
PHP is in my opinion the best solution when creating libre open-source software

It gives the widest amount of people the chance to selfhost for cheap.

You can get a PHP webhost for $5 per month including databases, some cheaper, some more expensive.

You dont have to worry about a VPS, Docker, Kubernetes, or anything like that. Hosting companies contribute by having "one click installs"

Sign up, pay you bill, click a button and you have your very own Wordpress instance and you can publish what you want.

If you create solutions that you want people to be able to self-host it is the best choice for now.

It is far from perfect.

WP has suffered a long string of severe security bugs. People have gotten their sites hacked

Some cheap hosters are not good. (I had great experience with a couple)

A lot of devs like to hate PHP and see it something awful from two decades ago. I understand that. There is truth in it. PHP from 20 years ago is quite different from PHP now. It is probably better than you think.

I would not start a project that needs to Google scale on PHP.

Nor would I expect a lot of people to have the ability to cheaply and easily self-host something like that.

but I like running my own Wordpress, my own file share solution, my own wiki and so on.

I can do all that dirt cheap thanks to awesome developers, PHP and cheap hosting.

Yet HN removed from the front page. Why the hate for PHP.
PHP’s popularity is not only due to Wordpress.

The language is simple and accessible.

The ecosystem and community are ginormous. Are you stuck on something? A quick Google search has the answer. Finding PHP developers anywhere is also easy.

It’s fast. No, really. And keeps getting faster.

It’s easy to run directly on your local dev environment.

It’s boring in a good way. Evolution is incremental. Breaking changes happen, but nothing unmanageable, and every version is supported for a long time.

There’s not a ton of confusing options to choose from, with the risk that they will eventually become obsolete/un maintained. Laravel and Symfony are pretty damn good.

Need to get something done quickly, just for a prototype? PHP ‘s a good choice. You will get there quickly, even if the code is not something you’ll want to show off with.

Need to choose a language for a web application that need to be maintained long-term? PHP is not a bad choice either, for all the reasons mentioned above.

There's something I don't like when people talk about PHP, and that's putting Symfony/Laravel and XAMP/shared hosting PHP into the same bucket. I feel like it's a dishonest way to present PHP as something it's not.

Symfony/Laravel PHP is basically like any other language, you could use Ruby with Rails, Python with Django, Java with Spring, Elixir with Phoenix and it's basically the same ballpark. But you give up the simplicity of setup and deployment.

XAMP PHP, on the other hand, is probably one of the most accessible way to do web programming, but isn't the same at all as Django, Rails or even Symfony/Laravel.

You use the same language, sure, but the two are very different beasts. You could probably add a third with the world of PHP-based CMS, like wordpress or drupal.

Everything you say is also true for Java or Kotlin, which are better languages and have even better backwards compatibility story. You also left out all the downsides of PHP so it looks more flattering than it should.

So while PHP is ok, why choose PHP when you can choose Java/Kotlin?

The only benefit of PHP over Java/JVM-langs is probably memory usage, which is generally not that important of a factor in today's environment where memory is cheap and devs are expensive.

I think unless you are already super familiar with PHP it's probably not the ideal choice. You could do worse, but you can also do better with Java/Kotlin/C# all of which have the good parts of PHP but none of it's bad parts, higher quality ecosystem, higher quality devs, better tools, faster runtime, etc.

lol 78% of total URLs, including parked domains on camper sites. So you have to count a parked domain page the same weight as youtube.com to get to 78%
And yet, Slack, Etsy, Wikipedia, WordPress, Mailchimp, Canva, Indeed, Investing.com are using PHP. I would think Wikipedia is a worthy competitor to youtube in this regard.
I suspect the success of PHP is binded to the success of BBOM architecture (http://www.laputan.org/mud/)
I counter that PHP could have been bigger if it wasn't because of all the BBOM stuff. I'm sure it scared away the OG devs in those days, thinking PHP wasnt worth their time.
Jeez, people, it's right there in the opening line.

> ... whose server-side programming language we know

How many of all the websites advertise their server language accurately? Everything else I've used in the past decade does not.

This seems to pop up on HN on a regular basis. I'm no fan of PHP (I've done my time thanks) but while I can't deny the popularity, these posts speak more to its users' insecurity than anything else.

In short: who cares? But judging by the comments, far too many people.

No tooling needed to deploy code is a massive contributing factor to PHP success.

It's maddening what's needed to deploy code for other web languages.

Most good languages are self-hosting with little/no dependencies.

Where you run into trouble is the scripting languages, i.e Node.js/Ruby/Python. You are best off avoiding these if don't like deployment nightmares.

PHP == “The COBOL of the web”
PHP is widely used because it is easy to use. In contrast with other programming languages that are complex, PHP is simple, fluent, clean and organized, hence it is a boon for the new users. PHP has a well-organized syntax which is logical at the same time