78% of the Web Powered by PHP
haydenjames.io
haydenjames.io
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.
PS. Sweet home theatre setup!
Try Typescript in your next project.
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".
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.
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?
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 made money writing PHP for a decade-and-a-half. Straight PHP is not particularly lucrative work; but Drupal module development can pay quite well.
For the "custom media playlist": VLC is just a player. But there's a player built-into your browser; my home-brew playlist originally used VLC, but I switched to using the <video> tag once it became reliable (and would play ogg/vorbis properly). You still need a backend; and you'll probably need quite a bit of Javascript.
Interesting. To use a very high level example, would something like the following work? Have a backend generate a webpage with a video from local storage playing via <video> tags, then refresh with javascript and have a different video playing?
Hang on - you said "from local storage". The video is played from server-side storage. If it was on local storage on the client, you could only play it on that client. So I take it you meant "local to the server", in contrast to online video resources.
Bingo. In switching over to pet project thought mode I started thinking "local to myself" rather than the usual client-server wording.
Thanks for the advice! That sounds genius. I can much more easily imagine implementing this with my existing skills compared to figuring out how to script VLC or some other media player.
Now I'm guessing this approach serves the server media file to the client browser, and the client browser then plays it locally. Would it be possible to create a kind of TV-channel/radio-station type of approach where the server is constantly playing a video, and any client on the network can hop onto the stream like a TV channel?
I imagine your media channel thing can be done, but I haven't tried it or thought about it. Not my use-case!
It's not "genius", BTW - I'm no media expert, not even a very good programmer. I'm just a tinkerer with an itch to scratch. And there's no way I'm sharing my code - it's a pile of crap, permanent work-in-progress.
I like the <video> tag very much, because it's cross-browser, and (IMO) is easier to script than previous players.
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.
I'm curious what you are basing that on?
PHP is not a fixed language. 8.0 was just released last year and has significant improvements. And has had several minor releases since (latest one being just weeks ago).
It has a package manager, a community of OSS libraries, tooling... everything a mature language has.
According to Github in the last month:
> 36 authors have pushed 311 commits to master and 329 commits to all branches. On master, 413 files have changed and there have been 19,469 additions and 7,581 deletions.
Not including popular libraries like CakePHP, Laravel, Wordpress, Drupal, etc. All of which are also very active with hundreds (if not thousands for some) of contributors.
That doesn't seem stagnant to me.
Edit: As a note, I don't even use PHP anymore (though I used to a lot in the past). I'm just confused by how someone can say it hasn't evolved with the times. If anything PHP has proven time and time again it is in fact willing to involve. With releases that make leaps and bounds for performance (with benchmarks) and add new more "modern" features consistently for over a two decades.
PHP 8 introduced a lot of great stuff but to me it's just about playing catch up to things like Kotlin, i.e null safe operator, etc. They made the runtime a lot faster with the JIT and the Opcache but it still pales in comparison to the JVM or CLR.
Type system is still not a real type system, it's more analogous to Typescript. I get why, it's because you can't turn around and make PHP backwards incompatible, but that is also why it can't ever be in the same class.
Meanwhile in JVM land you have things in progress like Loom which present a fundamental change in how highly concurrent applications can be built. Since Java 9 huge things landed like Jigsaw + ZGC and Shenandoah which are cutting edge GCs, not cutting edge for Java but in language-tech overall, i.e it's Java that sets the pace for what a modern VM looks like and that has been the case for some time now. v8 was perhaps more impressive for a short while until InvokeDynamic came along and escape analysis got better but these days JVM is pretty squarely in the lead with CLR closely following.
PHP won't ever be on the cutting edge and tbh, that is probably fine. Like I said, C isn't cutting edge and it's just as applicable as ever.
The difference between that and what people in this thread are arguing is they are saying things like "PHP is modern and generally good!" which just isn't true. It's improving and that is great, but modern and generally good it is not.
Doesn't stop it from being useful in the places it excels but as a general purpose language there are just better options.
> as a general purpose language there are just better options
I don't think PHP ever pretends or tries to be a general purpose language or cutting edge. But I think to say it hasn't evolved is a bit misleading.
PHP has always been a domain specific language.
It is designed to do one thing well: stateless request oriented applications with strong ability to scale horizontally. And for that, it does pretty well.
PHP developers are highly sought after in my fair Canadian city's web community. Not saying WordPress and PHP are ubiquitous, but the big players for web shops and even boutique agencies are using them.
It's my niche and one that's still lucrative, and since it's what industry needs and demands, it's what we teach at my workplace: a post-secondary college.
It may not be the best language or the best tool overall, but in my experience it almost always has been.
I don't think it's going anywhere anytime soon and it's constantly getting better, so I'm going to stick with my niche and keep turning to this really powerful tool.
I think it's similar to saying Python is the best choice for data science. It is. Not because it's a good language (it's not) but because due to factors like ecosystem it's the right tool for the job.
There is nothing wrong with embracing these local maximums.
I'm just tired of people asserting PHP is an -objectively- good/comparable language. Because it's not, for all of it's improvements it's still not close.
Is that ok? I think it is. Still solves problems effectively.
My "objectively inferior" language is Ruby. I use it all the time to do all sorts of things, little web servers, home automation, scripts on my desktop/laptop, etc. I like it, it works for me. Doesn't change the fact Ruby is flat out inferior to the languages I use at work.
OP didn't say this.
> No. It's simply not. We have come a long way since then and that view point can only be held out of ignorance.
> Language tech improved, PHP didn't come with it.
Are you familiar with the changelogs over the past 10 years? Are you ignorant of the changelogs?
> But to say PHP > Java/C#/Rust/Elixir/etc is just being an edgelord for the sake of it.
OP isn't saying that.
> 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.
Isn't this true of any language?
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.
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.
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.
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.
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/
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.
This isn't disagreeing with you, just saying that it is this way for cultural rather than technical reasons.
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.
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...
I wish PHP.net could get some support to provide official repos of their own. It would make upgrading easier.
[1] https://www.stackscale.com/blog/php-fpm-high-traffic-website...
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.
There has to be something like Wordpress for Web 2.0, so we can break the oligopoly of Facebook, LinkedIn, et al. and move the world from digital Feudalism to a Free Market:
So they stuck with Excel, even when they had access to a programmer.
Programmers can laugh all they want at Excel, Wordpress, PHP etc - but these are tools that get stuff done quickly and make businesses a ton of money. So businesses will continue to use them, even if there are much superior tools around.
I don't laugh at them. I see many people more clever than me working with tech I don't like, and making more money than I make. It's completely OK. I even wrote some PHP lately, and while my humble opinion generally hasn't changed (that I'm too dumb to use PHP), it's clearly VERY fast and easy to get started, while there are many people throwing money at you when you are good at it. If you are competitive and can work with weird setups (which is a given for many customers seeking freelancers), and under stress, then why leave money on the table.
Some may take what I'm saying like a snipe disguised as humility, but I'm completely honest. No sarcasm at all.
As of writing, at least, no one here is attacking your language.
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.
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".
Do create a discussion on GitHub though - would love to discuss this more.
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.
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.
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.
> 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.
I'm confused by this assessment. As far as I understand, it is not unusual for hosting providers to offer shared hosting that supports php, but not other popular server-side languages, and makes it possible to run Symfony or Laravel, but not Django, Rails, Spring, or Phoenix.
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.
Uhh no. Getting a local dev environment set up for PHP is much much easier.
Writing your first line of code and seeing things run in a browser is much much easier.
Uploading a single standalone PHP file you wrote to your 5$ webhost via SFTP, with _no other work required_ and just seeing your code run on your website? Show me how to do that exact thing in almost any other web programming language. You can't.
No one said PHP was perfect, and I'm not here to defend all the problems, but to compare PHP's almost universal accessibility and ease of use (which is why it is so popular) to something like Java or C# is ridiculous.
If you pay for a host that has all this setup and SCP/FTP your files to it sure, but is that -really- easier than the local dev experience vs the Sprint Boot starter pack? I don't think so.
https://www.jetbrains.com/help/idea/spring-boot.html
i.e Download IntelliJ, select Spring Boot, follow prompts to create project, press green button to run app. Click link in build output to open in browser, edit files for live reload.
To get equivalent usefulness out of PHP you would also need Laravel or some other framework, which if you want to do properly you also need Composer, etc. Ease of development is one area where Java is king these days, a LOT has changed in the last decade.
You're right, they are now at the same point in terms of ease of development. Deployment is close too (fat jar vs php files), though PHP still has shared hosting. And sure, Spring boot has more things that vanilla PHP.
> Uploading a single standalone PHP file you wrote to your 5$ webhost via SFTP, with _no other work required_ and just seeing your code run on your website? Show me how to do that exact thing in almost any other web programming language. You can't.
You can do this with Go and you don’t even need your webhost to have any special language support. Moreover, that single file can be an entire program, not just a single source file.
If you want to talk about something else, we can do that too.
Also, why would you distinguish Java/Kotlin/C# as something different then PHP? Java/Kotlin/C#/PHP they all mean the same to me. They're programming languages..
They are in a completely different class to PHP.
That is like saying a Honda Civic is the same as an Ferrari F1 car.
In that nobody uses a Ferrari F1 car to do anything practical?
Your bank is probably running 90% Java. Every large website you use may not be written in Java but relies on mission critical systems that are etc. It's an insanely practical language, in fact probably -the- most practical language and that is why it's chosen overwhelmingly for important systems that need a large number of developers.
I'm misconstruing the point because I don't like analogies, especially when they only bring confusion. There's no need to bring cars into a discussion about Java and PHP. Programming languages are programming languages, cars are cars.
> It's an insanely practical language, in fact probably -the- most practical language and that is why it's chosen overwhelmingly for important systems that need a large number of developers.
Java being practical is part of it, its marketing to managers is also part of it. But being the most practical language for "important systems that need a large number of developers" doesn't mean that it's the most practical language for everything. To answer your first question:
> So while PHP is ok, why choose PHP when you can choose Java/Kotlin?
When you're a single developer that does lots of small projects, PHP works really well. In a way, it allows you to go faster at first. Depending on your business, that may be the most important thing, or not important at all.
While my bank is surely running 90% Java, I would bet that there are many internal applications that saves people a ton of time that are written in PHP. That's how it was at my last job at <BIG COMPANY>.
Most programming languages are 'good'. Some are just better in doing certain stuff than others. Doesn't mean the other languages are bad.
Different doesn't mean worse, or better, without context.
For Java you can easily create a "fat jar" by dropping a plugin into your build system, usually with zero or minimal configuration. (shadow is the popular one for Gradle).
I am generally not a fan of Go (for a long list of reasons) but it's compilation speed and static by default (if you disable CGO, which you should) is definitely one of it's strong points.
Real type system -> PHP has one. Static analysis is possible in PHP. Sublime, PHPStorm and VS Code are not high quality? Zend Framework, Symfony, Laravel are pretty high quality frameworks IMHO
There is some minimal static analysis. Nothing in the realm of what is available for production languages.
PHPStorm/Webstorm are decent yes, IDEA platform is pretty awesome in general but if you think those are good wait until you try IntelliJ or Rider w/Java or C# respectively. There is good reason why it's those 2 editors that made Jetbrains into the company they are today. (Note that these too are written in Java and Kotlin... which should also tell you something)
Zend/Symphony/Laravel are great for PHP, orders of magnitude better than what came before them, however they just don't measure up to Spring and ASP.NET in performance, correctness and tooling. This shouldn't be a surprise either, Spring has a long history of massive production users, everything that can be done has been done and the best patterns and libraries have been battle tested in the harshest of environments. ASP.NET has insanely large userbase because it's the only blessed framework on the Windows platform, which is way larger than the HN community gives it credit. It has insanely high level of consistency because of the massive scope of both the C#.NET standard library and the bundled functionality in ASP.NET and blessed libraries like SignalR.
That is to say, can you use PHP for web? Sure you can, you can even build some great stuff. But unless you are invested in it already these other tools -are- better, objectively better, not subjectively.
You can argue subjectively for Python, Ruby or Node.js - to me these are all in the same class as PHP and have similar quality frameworks (Django, Rails, Nest.js) but are all objectively inferior to the production languages.
I don't even get why this is controversial tbh.
I have used all of these, in fact I still choose to use some of them. I build things in Ruby occasionally, Python for some things and I started off doing web stuff in Perl and PHP.
As someone with a background in all of these scripting languages I don't think it's possible without some crazy mental gymnastics to not see how the production languages are clearly superior for almost all professional use cases.
I think the most likely case is people that think otherwise just have never tried them, at least not seriously enough to really grasp them.
Just like Java then? Your average Java code will be more solid than your average PHP code of course, but Java is far from free from runtime errors due to a not good enough type system.
> You can argue subjectively for Python, Ruby or Node.js - to me these are all in the same class as PHP and have similar quality frameworks (Django, Rails, Nest.js) but are all objectively inferior to the production languages
> As someone with a background in all of these scripting languages I don't think it's possible without some crazy mental gymnastics to not see how the production languages are clearly superior for almost all professional use cases.
What is even a "production language"? Lots of people are using Ruby, Python and Node in production, and it's working very well for them.
> I think the most likely case is people that think otherwise just have never tried them, at least not seriously enough to really grasp them.
That's a strawman.
You seem to have a very black/white view about production vs non production languages, that mostly maps to "used by classical big companies", and that doesn't seem to reflect reality very well.
If Ferrari is so superior, why is that the case?
Hell why not buy a rocket ship. Its the most superior!
Oh yeah, not practical for most use cases.
> ... 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.
It's maddening what's needed to deploy code for other web languages.
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.