automattic/jetpack-autoloader
A custom Composer autoloader for WordPress plugins that prevents package version conflicts by building an in-memory classmap and always loading the latest available version of each class, no matter which plugin loads it.
vendor/ directory with whatever version it was built against, while guaranteeing the site loads the newest available copy at runtime. Without it, "shared library" effectively means "lockstep releases across every plugin," which is a roadmap constraint we'd otherwise have to accept.JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS and JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS) aimed at the two most common root causes of "worked yesterday, broken today" bug reports: classes autoloaded before plugins_loaded, and third-party autoloaders registered at a higher priority. That directly reduces time-to-diagnosis for support and gives us a documented first-response playbook.Consider it when most of the following hold:
vendor/ included.vendor directory, classmap-oriented autoloading, loading vendor/autoload_packages.php from the main plugin file, and generating an optimized autoloader in release builds.Look elsewhere when:
For executives — one paragraph. This is a small, free, Automattic-maintained component that eliminates a class of breakage we would otherwise inherit: two of our plugins, or our plugin and a partner's, shipping different versions of the same bundled library and fighting over which one loads. Adopting it costs us a build convention and a documented debugging setting; not adopting it costs us either lockstep releases across our plugin line or a stream of intermittent, hard-to-reproduce support tickets. The realistic risks are that it's an internal tool published as a mirror (so no external support contract), and that its guarantees only hold if everything in the shared-library path uses it.
For engineering — one paragraph. Add automattic/jetpack-autoloader as a Composer requirement, keep the default vendor directory, and require vendor/autoload_packages.php from the main plugin file. Release builds must generate an optimized autoloader (composer install -o). It builds an in-memory classmap from jetpack_autoload_classmap.php / jetpack_autoload_filemap.php and resolves each class to the highest semantic version present across all installed plugins using it. Three things to internalize: (1) the classmap is built once at load and is not refreshed after a plugin update, so never move or rename a class file in a way that could be autoloaded post-update; (2) version comparison is by package version, so moving a class into a newer package with a lower version number will silently shadow it; (3) don't autoload our own classes before plugins_loaded — that can pin an older version before the newer provider registers, and it will only show up when the plugin-discovery transient is invalidated. Turn on JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS and JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS in staging to catch both patterns early. Note that the repository we'd link to is a read-only mirror — development and issue tracking live in automattic/jetpack upstream, so file bugs there and pin a specific major version rather than tracking dev.
How can I help you explore Laravel packages today?