80% of the Web Powered by PHP (2017)
haydenjames.io
haydenjames.io
Everyone may commence the throwing of tomatoes now.
It is bad when working on a business-grade product with more than a dozen engineers. Bizarre language choices and an intrinsic tendency towards non-encapsulation seems to make even more spaghetti code than you'd find in Ruby, Python, Java, etc.
From working on numerous large Java projects, I can say with real-world experience that the logical equivalent to spaghetti code is very common with Java. The difference is where the spaghetti is -- in Java, it tends to be spaghetti inheritance and encapsulation.
Edit: Fixed some language errors and typos.
Of those PHP websites, most of them are probably wordpress. How many of those haven't been updated in ages?
That's way more dangerous than running PHP 5, taking into account all distros will backport security fixes for years to come.
Do you expect all node small and medium completed projects run on latest node?
For example by default the Website runs in PHP 5.6 and it is up to the site owner to change the local site version to a newer version via cPanel or similar.
So non technical users that just know a bit of PHP or use some CMS, end up being stuck with the default version.
Speaking as an ex-hoster here who had to look after a fleet of shared servers running PHP (000's of sites) for 15 years, sadly life is not that simple in the trenches. The major problem with PHP is breaking changes. Even within the 5.x releases there were enough breaking changes such that upgrading from say 5.3 to 5.6 could break a site. The jump from 5.6 to 7.x has enough breaking changes to make you cry. I think there should have been a commitment to maintain 5.6 for the next ten years, if only for security fixes.
Now I'm not suggesting that developers shouldn't go back and fix stuff that breaks because the PHP folks removed/altered that functionality (with the good intentions of encouraging more secure programming, for example), but there's a labour cost and someone needs to pay for that time.
There's also functionality in PHP that shouldn't have been removed (register_globals) but should have been defaulted to disabled. Sure register_globals is insecure but what we saw were folks adding the same functionality back, just google for "php emulate register_globals".
And don't get me started about the annoyance that was removing mysql_* support. Those exact same insecure string concatenated queries are still being executed via mysqli_* and the PDO libraries. In my experience, binning mysql_* didn't make a damn bit of difference when it came to sql injection attacks.
Don't get me wrong, I admire the efforts of the PHP core team, but they made a rod for our already sore support backs whenever a new release of PHP shipped because of some fairly unnecessary BC's.
mysqli_ has prepared queries, so it offers an immediate improvement.
The mysqli library was likely a full rewrite in another extension. Extensions, at least that kind, at that time, didn't use/have namespaces.
Keep in mind this is a legacy code base with a function called mysql_real_escape string, like if you're at that point you're so far past gone you've lost all hope.
for a 25 year library, thats not at all too bad. And even PHP developers admit that the lib was "not broken"
In the real world dropping the mysql_* API achieved next to bugger all, we still ended up with a bunch sites with exactly the same SQL injection vulns.
They did? All of them? Nobody moved to paramaterized queries?
1) this is not an argument for leaving an inferior library in the language
2) plenty of people do update their software, for old code and large projects. Why not push people toward the better library?
Only if they're used. If mysqli_ required prepared statements, then it would be different. But the sins that were committed with mysql_* could still be committed with mysqli_*.
The point wasn't "this fixed the injection problem" it was that it provided a solution not available for mysql_
it does for old code. and many people prefer a website with bugs than a website that doesn't work at all. And any website that was vulnerable to mysql_* attacks should have already been hacked out of existence by now.
>Those exact same insecure string concatenated queries are still being executed via mysqli_ and the PDO libraries. In my experience, binning mysql_ didn't make a damn bit of difference when it came to sql injection attacks.
Unlike ext/mysql, ext/mysqli and PDO both support server side prepared statements. If you don't utilize this properly, your argument is moot.
Official discussion points here: https://wiki.php.net/rfc/mysql_deprecation#why
The way I see it is new features, better practices, and greater security versus convenience. If the latter won, the former would need to be implemented on an ancient codebase, possibly opening up many new issues. If the former won and there's enough demand for ext/mysql, development may be continued by the community or at least shimmed on top of a proper extension or library. These decisions were being made while PHP was trying to gain traction in the "modern" web development community, making massive overall improvements leading to PHP 7+ due to pressure of Hack & HHVM, and doing a pretty damn good job with it.
Sure it sucked to convert existing code, but looking back, I'm glad I did, even if ext/mysql were still available. Luckily some of the larger, more abstracted codebases I've had to convert meant simply writing and swapping out an adapter. Most of the codebases I see nowadays still utilizing ext/mysql were clearly destined to bitrot regardless and now have far more important problems to worry about because they weren't designed to be maintained this long or they've been poorly maintained from inception. Good riddance.
Forming SQL by concatenating strings and variables is just bad practice and hopefully we can agree on that. ext/mysql provided no other option and this was just one of many issues with the extension.
Using ext/mysqli and PDO in a such a way (and I don't care if you're talking about retrofitting old code) is not even bad practice, it's just improper usage of the API when prepared statements should be used instead.
EDIT: Individually `print` `echo` `shell_exec` may be just as dangerous... It's up to the developer if they want to use them correctly.
and you don't have to install ext/mysql, they could just remove it from default configuration
"Non-technical" people who don't plan for maintenance costs to their software (including maintenance to keep up with dependencies like PHP) don't get a ton of sympathy from me ¯\_(ツ)_/¯
It's not just PHP. But Python 2x / 3x as well.
Just to point something out: this is one reason why Java is so well liked for large enterprise code bases. They have been religious about backward compatibility in new versions.
A 2nd principle I would advocate is that if there must be a breaking change, it should be caught at compile time, not at run time. The project should fail to build, and the errors point you to exactly where the source code problems are.
Other language systems would do well to embrace backward compatibility and build time errors over run time errors. IMO.
That was one of the lowest effort upgrades I ever did for my company (backend services, no front end websites).
One of the other reasons Java is popular in big companies is the low effort it requires to find people who can work with it.
If your application does a lot of ASCII/unicode/raw string and byte manipulation, the transition from Python 2 to 3 can be very cumbersome.
But at least the python folks provided some tooling to bridge the gap between v2 and v3 such as backporting features from python 3. Also minor version updates generally don't break whole codebases.
Apropos Java backwards compatibility, Microsoft has been pretty good at ensuring strong backwards compatibility with .NET code. I've seen .NET 1.0 source compile and run just fine on .NET 4. Hell I've even witnessed .NET 1.0 binaries run just fine without recompilation in newer .NET environments.
Sure there's breaking differences between .NET Standard and .NET Core but they're two different products and that was made pretty apparent from the get-go.
I mean, I agree with you. But Java benefits from well thought-out design constraints, ground-up IDE support, and an amazingly flexible bytecode interpreter. Normal people in the early 90s didn't have the resources to produce a language like Java.
It was for years! They deprecated the feature. It was default disabled in php.ini. And now, as you said, if you really still need it you can code it yourself (I had to).
> And don't get me started about the annoyance that was removing mysql_* support.
I'm pretty sure that library isn't supported by MySQL server anymore (it's their library) so that's why it was removed. You can even use it to connect to newer versions of MySQL as the protocol changed.
PHP has adopted a strategy of rolling version upgrades with defined end points. They probably should have some "LTS (Long Term Support) type releases.
http://php.net/supported-versions.php
5.6 just reached eol. I think they've put out a securtiy patch since then so its (not quite) completely abandoned.
If people aren't forced to upgrade their sites, they won't. So there is huge incentive to just keep running the older versions.
Debian 8 (Jessie) still has a little over a year left, for example, and is on PHP 5. Ubuntu 14 is just nearing the end of support, and is on PHP 5. Same with OpenSUSE and CentOS.
I'm not sure what the Red Hat situation is, because the pages at Redhat that Google found that would probably tell me are in the knowledge base, and will only show me the question, telling me I have to be a Red Hat subscriber to see the answer.
This is one of the annoyances with some major frameworks. According to both the Symfony and Laravel requirements pages, they need PHP 7.1.3. As far as I can tell that's not included in any LTS release of any major Linux distribution, which top out at 7.0.33 currently, I believe.
PS: interesting oddity somewhere in HN. When on the "reply" screen for your comment, HN says your comment is 1 day old. However, back in the thread, or on a direct link to your comment, it says that it is 6 hours old. It does the same thing for all 6 hour old comments in this thread, but not 5 hour old comments.
Oh you cant run lib/framework/tool due to host deps? No problem, I will just replace you with a script.
Which are the "right extensions" because what I saw was not "fun" at all.
PS: I haven't used php for 2 years, let me know if there is an update on debugging.
I am not sure how well such a feature is supported in javascript, ruby, java or what not out of the box...
Aside from that, I'm glad you've highlighted Laravel, which—despite being the most popular server-side Web framework on GitHub—gets virtually no attention from HN. It's typical to use Laravel in the old server-side rendered Rails paradigm (which is still probably best for some applications), but I've had success using it to develop APIs as well. Core features like the ORM, job queues, dependency injection, email templating, etc, are very solid, and the ecosystem of packages around it is phenomenal. I would recommend it to any Web developer.
PHP can scale up or down, but some tools are harder to 'scale down' - by that I mean be able to be used for short one-off things (cli tools, etc). I'm not saying it can't be done, but people don't often write smaller supporting tools (quick text preprocessing before an import, for example) in Java, even when their main projects are in Java. Of course, IME, and YMMV.
[1] https://venturebeat.com/2015/11/08/wordpress-now-powers-25-o...
https://wordpress.org/news/2019/03/one-third-of-the-web/
That's the entire web. It is staggering.
I guess it's like how people trashed COBOL and Fortran when I was getting into development. Then later in life, I come to find out that Fortran is ubiquitous in engineering and is actually amazing for what it does.
Unlike many programmers, I don't pick one of the Turing-complete programming languages (PHP, Python, Ruby, Go, whatever) and try to write as much of my app as possible in it. Because they are Turing complete, you really can write everything in it. Because you can learn only so much, you are tempted to write more than you should in that language.
But like I said, PHP is just a part of my stack, and I try my best to make it one of the thinnest layers. The other parts are Postgres, Apache, and the user's browser. I try to use each of those as much as possible. The server operating system also plays a part, and I suppose my stack includes Bash.
Basically I try to do as much business logic as possible in Postgres. This leaves PHP to do little more than glue the output of Postgres to HTML templates.
Because we all abuse it, and is damn easy to make it work.
But at the end, we all feel dirty for using php.
they have tons of other metrics. To summarize PHP and Wordpress absolutely dominate the web.
Well PHP 5.6 is unsupported aswell, but it was supported till december 2018..
End of upstream support is meaningless in a world where most servers run LTS distros of one flavor or another. I've been telling my clients that they should be able to rely on PHP 7.2 for a long, long time because it's the default version in Ubuntu 18.04 and RHEL/CentOS 8, both of which come with 10 years of support.
1. Bunch of up-and-forget sites on shared hosts
2. A metric ton of legacy codebases that plain don't work on PHP > 5.5
3. PHP 7 had quite a few breaking changes, like you mentioned
4. LazinessAlso php7 breaks most old projects
Heck, even with Wordpress these days you could use it as an API source and build a modern SPA website. It’s just getting over the inertia of intransigent stakeholders.
Website: main focus is information serving, documents, designs, texts, assets, etc.
Webapp: users can create some kind of output from the service that's based on creative input.
The line is still blurry, but more narrow and contrasted.
Or, a simpler definition: a webapp is any website that you can’t effectively host on your ca. 1995 ISP’s web hosting.
Many webapps where the “app” is purely in a CMS backend (e.g. most Wordpress sites) are websites. Unless they include comments, in which case they’re not. Unless those comments are JavaScript-embedded third-party (e.g. Disqus) comments, in which case they are. :)
But even ignoring that, I also define the terms this way because of the prefix "web." A webapp isn't "an app on the web", but rather "an app powered by the web." An entirely-offline JavaScript SPA that is just served over the web, isn't a web-app. It's just a program that runs in a browser, just like a Flash or ActiveX or Java applet is a program that runs in a browser. (Is a Flash game a "web game"? It's usually considered a browser game, but that's not the same thing.)
We already have a term for the thing that {Flash, ActiveX, Java} applets are: apps. Offline JavaScript SPAs are just apps too. We don't need to add the prefix "web"; it's meaningless here. In any of those cases, if you took the exact same program, and slammed it into an Electron wrapper instead of into a domain-fronted S3 bucket, it would clearly not be a "web app" in any sense. Your SPA would just be "a JavaScript app that uses a browser DOM as its graphics toolkit." Well, that's just as true before you put it in the Electron wrapper.
So "web app", then, has a specific meaning, above and beyond "app." You need something extra. That something extra is a backend, which your browser—driven by the app's logic—interacts with over the web. That's what makes an app "a web app." (This definition intentionally encompasses both server-rendered dynamic HTML, and client-rendered JavaScript SPA apps. You don't need a frontend app; you just need a web backend that something is interacting with. That something can be the browser directly, by clicking links and submitting forms; or it can be a JavaScript frontend, using AJAX.)
A "web site", then, is a "web app" without the "app" part. If it's clear in the above definition what an "app" is, and what a "web app" is, then you can subtract one from the other to derive a definition of a "web not-app." That's a website: something powered by a web backend, which does not do any app things. If we decide that "app things" are basically "storing state", then a "site" is an "app" with no persistent state.
And since the definition of "web" here is about a backend, then the difference between a "web app" and a "web site" (a web not-app) is probably defined by the properties of the backend. So the difference about the ability of the web backend to store state. So a "web site" is a "web app" where the backend does no app things—i.e., stores no state.
It's currently taking #4 place in the famous framework benchmark:
This is why.
We are building a Wordpress-like decentralized open source alternative to Facebook and Google.
Sure, but why? Why one should discard proven,highly performant and well working solution with tons of already written and ready to use high quality frameworks and libraries? Why one should try to replace internet's "workhorse" with FOTM language/solution? Just because of hype on reddit and HN?
I know that PHP (and Java) is out of fashion right now but it's worth to be calm, ignore buzzword hype and use best solutions for problems.
The world isn't black and white and will never be. Don't oversimplify.
Truth be told, we will soon just need a bunch of open HTTP servers listening on the internet, and we will tunnel end-to-end encrypted traffic through them for signaling/matching clients by key and perhaps TURN relays. We already have 40,000 installed users and growing, our apps that run on people’s home computers will be able to make sure that stuff is secure and validated and enforce consensus with MINIMAL CPU power. We made the mistake of doing proof of work mining in the past and quickly removed it:
https://www.google.com/search?q=qbix+mining&ie=UTF-8&oe=UTF-...
I think DNS is eventually going to go the way of the dodo, and we will have this:
https://qbix.com/blog/2018/08/28/vision-for-a-new-truly-dece...
PHP scales down better than just about any other language out there since most of the rest of them have to boot up.
If you want to power some little dynamic things like blog comments you can run a custom microservice in a less awful programming language, or go with some hosted cloud option like AWS AppSync or Aurora Serverless.
The "all in one package" solution is a lot more complex than you make it sound. I would argue that much of the 80% of the web powered by PHP would be well-advised to utilize cloud services.
What they're measuring isn't the number of websites that use a particular technology, but the number of websites that report they're using a technology. In the case of PHP that means expose_php is set to true in the ini file, and Apache is configured so use "ServerSignature On". Those are the defaults, and they're arguably bad defaults because gathering information about a target is Hacking 101. You definitely shouldn't be giving away version numbers unless you're really good at patching stuff on day 1.
What this survey means is that PHP gives away data about your web apps internal structure. Most other web technologies don't do this. The defaults are more sane. They're not adding x-headers to every request about what versions of which technologies the server is running.
If you dig a bit you'll see this line in the source data: "PHP is used by 79% of all the websites whose server-side programming language we know." (https://w3techs.com/technologies/overview/programming_langua... under "How to read this diagram")
tl;dr PHP server admin need to get better at security.
I do agree that exposing the version isn't a great idea.
Handy reference from the Wappalyzer browser extension for you.