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.
Architecture fit. jetpack-autoloader is a drop-in replacement for Composer's default vendor/autoload.php tailored to the WordPress plugin ecosystem. The core problem it solves — multiple co-installed plugins each bundling a different version of the same PHP package, causing "class not found," fatal redeclaration, or wrong-version behavior — is real and common in WordPress, where there is no single dependency resolver across independently shipped plugins. The design is a classmap that is rebuilt into an in-memory registry on every request; whichever plugin loads the autoloader first triggers a scan of all co-installed plugins using the loader, then the map is updated to point at the highest semantic version of each class. This is architecturally sound for a portfolio of first-party plugins that ship independently but share code, which is the classic Jetpack scenario. It is not a fit for single-plugin applications, non-WordPress PHP services, or any scenario where third-party plugins cannot be forced to adopt the same loader.
Integration feasibility. Low code change surface: add automattic/jetpack-autoloader to composer.json, run install, and replace the require vendor/autoload.php line in the main plugin file with require_once plugin_dir_path( __FILE__ ) . 'vendor/autoload_packages.php';. Constraints: the project must use the default vendor directory; new Jetpack packages should use classmap autoloading (which also satisfies WordPress Coding Standards for file naming); PSR-4 works unoptimized but the classmap path is preferred via composer install -o. The real cost is coordination, not code: the loader's correctness guarantee ("always load the latest version") only holds if every plugin sharing the package uses this loader. Any plugin using a stock Composer autoloader, or one registered at higher priority, reintroduces the conflict.
Technical risk.
JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS to detect this in staging.JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS to catch classes autoloaded before plugins_loaded.Last release: 2021-03-30, Stars: 53, and Dependents: 0 are misleading: this is a read-only mirror of a subpackage of the Automattic/jetpack monorepo, and the changelogs show active 5.x releases. Treat the mirror metrics as non-signal and evaluate against the upstream monorepo.NOASSERTION requires a legal review before shipping in a commercial product; Jetpack is generally GPLv2-or-later, but confirm.JETPACK_AUTOLOAD_DEV flips version preference to dev builds — must be controlled by environment, not committed to production config.Key questions.
composer install -o and does it exercise JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS / JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS in staging?Stack fit. PHP 7.x+ / WordPress / Composer. The package is a Composer plugin that generates vendor/composer/jetpack_autoload_classmap.php and jetpack_autoload_filemap.php, exposing a single entry point at vendor/autoload_packages.php. It is agnostic to other WP-specific concerns (hooks, DB, i18n) and coexists with autoload.php in the same vendor tree as long as plugins point at autoload_packages.php. It composes well with a monorepo strategy where each plugin is a separately released artifact built from a shared source tree.
Migration path.
composer install -o, and verify class resolution under each co-installed combination in staging.EARLY_LOADS, CONFLICTING_LOADERS) and keep them off / opt-in in production.Compatibility.
Sequencing. Pilot → cohort rollout → debug-constant hardening in CI → cleanup of legacy loaders. Do not interleave with unrelated dependency upgrades; the failure modes are hard enough to isolate without confounding changes.
Maintenance. Small, stable code surface. Changelog history shows a long tail of "internal updates" plus occasional fixes (e.g., double-slash path fix in 5.0.8) and production-build exclusions (5.0.9). Major versions have moved (1.x → 2.x → 5.x), so we own the upgrade path and API-drift risk — no upstream team will upgrade us. Budget a recurring review per release train.
Support. No first-party support channel for this mirror; issues are tracked in the Automattic/jetpack monorepo. In practice, support means internal expertise: whoever operates this needs to be fluent in Composer autoload internals, WordPress plugin load order, and the three debug constants (JETPACK_AUTOLOAD_DEV, JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS, JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS). Document a runbook for "intermittent class not found on plugin update."
Scaling. Runtime cost is a one-time classmap scan plus transient-cached plugin enumeration; negligible per-request impact for realistic plugin counts. The transient is the scaling lever and also the scaling liability: cache misses will be visible as latency spikes on cold starts, and cache invalidation is the mechanism by which latent bugs appear. No external network calls. Memory footprint scales with the number of co-installed plugins using the loader — fine for a portfolio, but plan to audit if plugin count grows into the dozens.
Failure modes.
DEBUG_EARLY_LOADS, enforce that class autoloading in plugins happens after plugins_loaded.DEBUG_CONFLICTING_LOADERS, adoption gate in release checklist.JETPACK_AUTOLOAD_DEV is not defined in prod builds.NOASSERTION surprise on distribution → mitigation: legal sign-off before external ship.Ramp-up. Team learning is moderate, not trivial. Engineers need to internalize: (a) the loader must be first in the cohort, (b) autoloading must be deferred to plugins_loaded, (c) class file locations are frozen per release, (d) debug constants exist and should be flipped in staging. Expect 1–2 sprints of ramp-up plus a written runbook before first production rollout; after that, day-to-day cost is small. The primary operational success factor is organizational discipline (cohort-wide adoption + release hygiene), not engineering complexity.
How can I help you explore Laravel packages today?