As I looked through the link to the repo attached in the answer, I noticed the incredible amount of requice
statements in a single file. The main problem is that the repo is missing a autoloader that can be optimized project wide and as well as that the plugin includes all those files no matter if needed or not.
When you start using Composer to manage attachments, you will find that it creates an autoload.php
file for every single package that you write (or fetch). You can then create complete projects using Composer as package manager, which, as a nice side effect, also creates a centralized autoload.php
file instead of one autoloader per included package (plugin/theme/etc). On top of this single autoloader, Composer also builds a "Class > File" map as "cache" to avoid as many disk reads as possible, which will keep class lookups as fast as possible.
This will avoid having to namespace vendor namespaced classes. Meaning that in case multiple packages have a composer.json
file, there will be only one location where those vendor packages will get saved (therefore saving bandwidth and disk space) and fetched from. Even if one did not ignore vendor files in a VCS controlled package, there is no need to load them anymore.
# Before in Package (A)
$stripe = new \MyRadNamespace\Stripe;
# Before in Package (B)
$stripe = new \MyFunkyNamespace\Stripe;
# After – anywhere!
$stripe = new \Stripe;
In case a plugin or theme does not support Composer yet, you can simply fetch it via the WPackagist proxy/mirror service.
To get a quick start with the Composer package manager, I suggest using wecodemore/wpstarter by @gmazzap – docs here.