3 ms·
I am not fond of Bedrock. (Acorn maybe solves a problem though) Subverting the way WP works to make it work more like other environments is, in my long experie
by throw46365 2y ago
I am not fond of Bedrock. (Acorn maybe solves a problem though)
Subverting the way WP works to make it work more like other environments is, in my long experience with WP, the cause of almost all unmaintainable, hacky sites, no matter how good the intentions.
It’s entirely possible to use Composer and the autoloader within a plugin without doing stuff like this.
I tend to wrap up every plugin I write using Composer, and enclose the plugin’s functionality in a singleton instance.
If you are not then also targeting the WP plugin repository, you can make good use of PHP lambda functions to make tidier code.
But generally, it’s just better not to assume the WP conventions are wrong; almost all the interoperability of WP comes from understanding its idiosyncratic way of doing things, and leaning on simplicity and the core whenever you can.
- chuckadams 2y agoDon’t make the mistake of believing the default settings of WP come from any kind of informed wisdom instead of historical accident. WP was never designed, it was grown, it predates composer and every sensible modern PHP practice, and is still distributed the same way for compatibility reasons. For all its faults tho, WP does let you rearrange its half-dozen or so directories, and is designed to do so. Bedrock’s layout isn’t radically different from what many multi-user WP setups adopt. WP itself uses constants everywhere to refer to its directories, and as long as you set them, WP will work fine. Plugins that hardwire paths have to be fixed of course, but even the dumbest plugins still tend to use the constants, or are easily edited to do so. (BTW, I recommend cweagans/composer-patches for those plugins you do need to tweak by hand: much more maintainable than forking the plugin locally)
- throw46365 2y ago> Don’t make the mistake of believing the default settings of WP come from any kind of informed wisdom instead of historical accident. I don't, thanks. To repeat myself, I just say it's better not to assume they are wrong. Almost every bit of bad WP development out there comes from people who work against the flow of what WP is doing, whether because they don't understand or do understand and feel they know better. They may, in fact, know better, but it's almost always wasted energy that leads to future unmaintainability when a WP site is handed to a new stakeholder for example. The WP sites I've had to maintain where someone has subverted the templates, or tried to superimpose some MVC scheme, or whatever, have always been the worst ones. There are good, official tools to manage most of the idiosyncrasies of WP (WP-CLI, for example) without just arbitrarily moving stuff around. Learning them helps.
- chuckadams 2y ago> To repeat myself, I just say it's better not to assume they are wrong. Normally advice I would heed, but my long experience with WP's codebase has flipped that assumption. It's WP's default layout that's the unmaintainable mess, much like every other legacy PHP project that doesn't use composer. Bedrock isn't "arbitrarily moving stuff around": it's a mature product maintained by people who know what they're doing, which frankly puts them a tier above most of Automattic. I use wp-cli alongside bedrock, they work nicely together.