Weave Code
Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Jetpack Autoloader Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Technical Evaluation

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.

  • Correctness depends on adoption completeness. Mixed-loader environments are the single largest risk; the package explicitly documents that it "may not be able to control which version of the package is loaded" in that case. Enable JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS to detect this in staging.
  • Transient cache masks early-load bugs. The loader caches the plugin list in a transient; when it is invalidated, previously dormant load-order bugs surface intermittently. Enable JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS to catch classes autoloaded before plugins_loaded.
  • Post-update path staleness. The in-memory classmap is built once and not refreshed after a plugin file move or rename; classes moved during an update can produce load errors. Discipline is required: do not move/rename class files or change namespaces without ensuring the old class is not loaded after update.
  • Cross-package version inversion. A class moved into a new package with a lower version number than the old package is shadowed by the old one — a non-obvious failure mode that will surface as "my new code isn't running."
  • Metadata reliability. The listed 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.
  • License. NOASSERTION requires a legal review before shipping in a commercial product; Jetpack is generally GPLv2-or-later, but confirm.
  • Debug constants are production-relevant. JETPACK_AUTOLOAD_DEV flips version preference to dev builds — must be controlled by environment, not committed to production config.

Key questions.

  1. Which of our plugins will co-install and share packages, and do we control 100% of them?
  2. Are any shared packages also shipped by third-party plugins we cannot force onto this loader?
  3. Who owns the upgrade cadence for this package, and what is our policy on major-version bumps (1.x → 2.x → 5.x)?
  4. What is the licensing position on GPLv2-or-later for our distribution model?
  5. Does our CI run composer install -o and does it exercise JETPACK_AUTOLOAD_DEBUG_EARLY_LOADS / JETPACK_AUTOLOAD_DEBUG_CONFLICTING_LOADERS in staging?

Integration Approach

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.

  1. Inventory all first-party plugins and their Composer dependency graphs; identify overlapping packages and current bundled versions.
  2. Adopt in one plugin as a pilot: add the dependency, switch the entry point, run composer install -o, and verify class resolution under each co-installed combination in staging.
  3. Adopt across the cohort: roll the loader into every plugin that shares packages, ideally in the same release train so no window exists where one plugin is on stock Composer and another on Jetpack loader.
  4. Enable debug constants in staging CI (EARLY_LOADS, CONFLICTING_LOADERS) and keep them off / opt-in in production.
  5. Decommission legacy custom autoloaders and remove duplicate package copies from plugins that no longer need their own vendor tree (optional; the loader tolerates duplicates but version shadowing remains a concern).

Compatibility.

  • Autoloader standards: classmap preferred; PSR-4 supported unoptimized; PSR-0 converted to classmap. Align new Jetpack package authoring to classmap + WordPress file naming.
  • Loader ordering: document that this loader must not be preempted by another Composer autoloader at higher priority. Where plugins currently register their own spl autoloaders, either remove them or ensure they don't claim packages this loader owns.
  • Composer version: verify the Composer plugin API version used by the package against our Composer version (the 5.x line targets modern Composer 2).
  • WP minimum version: not pinned in the README; treat as "modern WordPress" and verify against our supported matrix.

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.

Operational Impact

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.

  • Intermittent class resolution errors after transient invalidation → mitigation: DEBUG_EARLY_LOADS, enforce that class autoloading in plugins happens after plugins_loaded.
  • Conflicting autoloaders in mixed environments → mitigation: DEBUG_CONFLICTING_LOADERS, adoption gate in release checklist.
  • Stale class paths after plugin update that moved/renamed a file → mitigation: forbid file moves in release deltas, or ship moves as a separate release with the old autoloader still resolvable.
  • Version-inversion shadowing when a class moves to a lower-versioned package → mitigation: package versioning policy (new package must have version ≥ old), pre-release review.
  • Dev-version leakage to production → mitigation: environment-scoped constant, CI assertion that JETPACK_AUTOLOAD_DEV is not defined in prod builds.
  • License/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.

Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
robinflyhigh/livewire-datatables
rudashi/optima
misakstvanu/laravel-fortify-passkeys
insology/laravel-fatture-in-cloud
roundly-consulting/workflows-for-laravel
ipregistry/ipregistry-php
quellabs/canvas-smarty
quellabs/signal-hub
goodport/laravel-js-error-logger
szabrob/laravel-billingo
devkussema/acapapay-laravel
apartejs/laravel
smronju/nativephp-geolocation
luppakorva/laravel-nist-password-rules
owenmelbz/sashimi
gui1535/sql-to-eloquent
hashtap/laravel-responsecache
pnscripts/laravel-proverka-lite
bhawdeadlydan/laravel-accountkit
jlawrence/eos