inpsyde / WP-Stash

Bridge between WordPress and StashPHP, providing a PSR6-compliant caching system for WordPress
https://inpsyde.com/en/wordpress-caching-system-wpstash/
GNU General Public License v2.0
51 stars 12 forks source link

When using only composer #4

Closed szepeviktor closed 6 years ago

szepeviktor commented 6 years ago

Should I add wp-content/mu-plugins/wp-stash.php with

<?php

require __DIR__ . '/wp-stash/wp-stash.php';

when I use composer without WP Starter? Could you include it in the README?

Biont commented 6 years ago

My suggestion would be to employ a muplugin-loader package for this purpose, like

https://github.com/bueltge/must-use-loader

or

https://github.com/lkwdwrd/wp-muplugin-loader

But yeah, since it gets installed in a subfolder, it won't show up in a plain composer installation as WP will only load top-level php files as mu-plugins. I guess this warrants a note in the README, agreed

szepeviktor commented 6 years ago

Thank you.

I consider putting a complete plugin among MU plugins an anti-pattern. An MU plugin should be UI-less and tiny.

This is a small MU plugin against must-have plugin deactivation :) https://github.com/szepeviktor/wordpress-plugin-construction/tree/master/mu-protect-plugins

Biont commented 6 years ago

It's just the nature of using composer that packages get installed in subdirectories which conflicts with the way WP will attempt to load mu-plugins.

This does not have anything to with loading regular plugins as mu-plugins (although this becomes possible due to the similar folder/file structure).

This is just a situation where you can't please everyone:

szepeviktor commented 6 years ago

and so far nobody has complained

I try to keep all sites' code base as small as possible, sparing single lines!

Biont commented 6 years ago

Sorry, I am unable to see the connection between that comment and the quote it's referring to.

szepeviktor commented 6 years ago

The linked plugins like bueltge/must-use-loader are hundreds of line for only 1 require statement.

I could imagine a Composer loader that creates one file for every MU plugin, e.g. require __DIR__ . '/wp-stash/wp-stash.php';

Biont commented 6 years ago

I see. Yes. We also use "handwritten" mu-loader-scripts in a couple of projects where WP Starter is not an option.

This is of course entirely down to personal preference.

Biont commented 6 years ago

When I linked bueltge/must-use-loader earlier, I admittedly only checked if it roughly did what I expected it to do based on the readme. On closer inspection during updating the WP Stash docs, I realized that it is indeed a kinda weird solution for the problem at hand. So I did not include it as a recommendation in the docs.

szepeviktor commented 6 years ago

Thank you @Biont !