top | item 17015064

A Crash-Course in PHP Namespaces for WordPress Developers

56 points| eamann | 7 years ago |stevegrunwell.com | reply

31 comments

order
[+] firefoxd|7 years ago|reply
The WordPress ecosystem is the one place we need this the most. Adding a plug-in to your wp instance is always a gamble because you know it's gonna break something else.

Kudos to the author for helping solve a real problem.

[+] jstewartmobile|7 years ago|reply
Namespaces are more like a mitigation than a solution.

The problem is tight-coupling. Until that is addressed, plugins will always be little fail-bombs.

[+] debacle|7 years ago|reply
The fact that WordPress and other large projects still support PHP 5.* is one of the major things holding PHP back. Supporting PHP 5.* in 2018 is like supporting IE8 in 2018.
[+] smacktoward|7 years ago|reply
It's a classic chicken-and-egg problem. WordPress supports ancient versions of PHP because they want to be deployable on as many web hosts as possible, including ones that only provide ancient versions of PHP. And web hosts provide ancient versions of PHP because their customers (lots of which are WordPress users) don't demand they provide more recent ones.

It would be a huge help to the overall PHP ecosystem if WordPress started required PHP 7, as this would cut the knot and give those slow-moving Web hosts a reason to upgrade. But requiring PHP 7 would be a much smaller help to WordPress itself, as there's nothing in PHP 7 that WP really needs to do what it does, and dropping PHP 5 support would mean creating a non-trivial number of people for whom WordPress no longer "just works." (As the article notes, PHP 5.2 users only account for around 4% of the overall PHP audience, but the overall PHP audience is huge and 4% of "huge" still equals "a lot.")

So to a degree, asking WordPress to drop support for PHP 5 is asking them to take one for the team. It would be nice if they would, but I can understand why they wouldn't want to.

[+] toast0|7 years ago|reply
WordPress and other large, popular projects got where they were by meeting their users where the users already are.

If I have to convince my webhost to install PHP 7 or I can't run your software, I'm not going to run your software. If I have to convince my webhost to install PHP 7 or I can't upgrade your software, I'm going to run the shitty old version until it gets hacked into a distribution site and the bandwidth use gets high enough for me to notice and turn the whole site off.

I'm not familiar enough with PHP these days to know, but if upgrading to PHP 7 is going to break the shitty old version, that's a problem too. (I think PHP has tended to be pretty good about not breaking things on upgrades though)

[+] jccc|7 years ago|reply
I'm genuinely happy for you that your work doesn't labor under the constraints that many, many (many) environments in the real world require.

But that doesn't mean those places/organizations/projects don't exist, even if you're unaware of them or don't think they're worthy of WordPress developers' efforts.

[+] johnnyfaehell|7 years ago|reply
Holding PHP back? It powers the majority of websites. Seems it’s pretty dominate in the area it was built for.
[+] aussieguy123|7 years ago|reply
Look at the drupal source code on github, its all namespaced. The over a decade old wordpress core codebase is still old procedural style PHP.
[+] esaym|7 years ago|reply
How is this news? Been doing this in perl since 1995.