4 ms·
It is having quite the renaissance. Unfortunately, a lot of long standing PHP code bases remain vanilla with globals everywhere are bad practices. Nothing wrong
by jjice 4y ago
It is having quite the renaissance. Unfortunately, a lot of long standing PHP code bases remain vanilla with globals everywhere are bad practices. Nothing wrong with vanilla PHP, but it really starts to limit what you can get done when you have a very transaction script[1] oriented code base and there are no good abstractions and layers.
I'd say the issue isn't PHP (8.1 is actually packing a ton of awesome features), but more so old PHP programming practices that are still very prevalent.
[1] https://martinfowler.com/eaaCatalog/transactionScript.html https://martinfowler.com/eaaCatalog/transactionScript.html
- freedomben 4y agoThis is a lot of what I'm seeing. You can write a nice, pleasant application with laravelle, but so many of the existing PHP developers don't write code like that. They use the horrible practices that they started with. I don't know how the PHP community is going to overcome this, and failure to will hurt adoption.
- tehbeard 4y agoI mean, the same is true of javascript, part and parcel of having a low barrier to entry is that people who put low effort into their work can use it... As to how we're sorting that; pretty much the only major project I can think of that I'd describe as "actively legacy" in its codebase/style is WordPress, and that's a hairy discussion around moving forward vs. backwards compatibility of their plugin/theme ecosystem which is their primary USP. Practically every other serious project has moved to the composer/PSR-4 autoloading model, and a lot of them also make use of static analysis/linting tools to squash potential bugs and enforce standards. If you're a web dev company that values maintainable code you can weed out these legacy slapdashers in recruiting. And those legacy projects out in the wild? Not my concern until someone brings one to us saying they want x feature added, we point out the Y,Z and Q faults / security issues with their slapdash code, and negotiate a price on a sane rebuild that'll be maintainable going forward. It may be a bit of mess, but it's being made better little by little each day, and the naysayers can complain about PHP all they want, I'm still getting paid to write PHP.
- stjohnswarts 4y agoWould you say it's similar to the problems that modern c++ has with older (pre c++-11 even) code? I quite like modern c++ and use it along with rust, but haven't done a lot with older code bases (my definition being before the c++11 standard became commonplace) . We enforce it at work, although we have a few c libraries in the mix, that we plan on "rewriting" when "we" get the chance (I don't see that happening :) ) . Just curious. I have done nothing in php other than a couple of silly examples and setting up a couple servers to use wordpress.