Weave Code
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

Jetpack Autoloader Laravel Package

automattic/jetpack-autoloader

Composer autoloader drop-in for WordPress and PHP projects that avoids class conflicts across bundled plugins/themes. Provides a custom autoloader to isolate vendor libraries, improve compatibility, and reduce “cannot redeclare class” errors in complex installs.

View on GitHub
Deep Wiki
Context7

[READ ONLY] Autoloader for Jetpack. This repository is a mirror, for issue tracking and development head to: https://github.com/automattic/jetpack

Frequently asked questions about Jetpack Autoloader
Can I use automattic/jetpack-autoloader in a pure Laravel project without WordPress?
No, this autoloader is tightly coupled to Jetpack’s WordPress ecosystem. It relies on WordPress’s `register_autoload()` and Jetpack’s global class structure (e.g., `Jetpack_*`), which won’t work in standalone Laravel. Use Laravel’s native Composer autoloader instead unless you’re explicitly integrating Jetpack.
How do I install this package in Laravel without breaking the existing autoloader?
Install via Composer (`composer require automattic/jetpack-autoloader`), but manually load it *before* Laravel’s bootstrap in `bootstrap/app.php`. Use a service provider to wrap Jetpack’s `jetpack_autoload()` and ensure it doesn’t override Laravel’s `SplClassLoader`. Test thoroughly for namespace collisions.
What Laravel versions does this package support?
It’s compatible with Laravel 8, 9, and 10, but requires manual sequencing in your bootstrap files. The package itself doesn’t enforce Laravel-specific logic, so version support depends on your WordPress/Jetpack compatibility. Always test in a staging environment first.
Will this autoloader work with Laravel’s Facades or Service Providers?
No, it won’t integrate natively with Laravel’s Facades or Service Providers. Jetpack’s autoloader operates at a lower level (global class resolution) and may conflict with Laravel’s PSR-4 autoloading. You’ll need a custom wrapper or abstraction layer to bridge the two.
Are there any known conflicts with popular Laravel packages like Laravel Mix or Forge?
No direct conflicts with Laravel Mix or Forge, but Jetpack’s global classes (e.g., `Jetpack_Admin`) could clash with third-party packages using similar names. Always audit your `composer.json` for overlapping namespaces and use fully qualified class names where possible.
How do I test this autoloader in a Laravel environment?
Test by mocking Jetpack’s dependencies in PHPUnit and verifying Laravel’s `ClassLoader` isn’t disrupted. Use Laravel’s `app()` helper to check if Jetpack classes are resolvable without breaking your application. Test edge cases like missing Jetpack modules or autoloader initialization failures.
Is there a way to make this autoloader PSR-4 compatible for Laravel?
Not natively—Jetpack’s autoloader relies on WordPress’s custom `register_autoload()` logic. You’d need to fork the package, rewrite the class resolution logic to use PSR-4, and submit changes upstream (though Automattic has shown little interest in maintaining this repo). A wrapper class is a safer alternative.
What happens if the autoloader fails during Laravel’s bootstrap?
If Jetpack’s autoloader fails (e.g., due to missing dependencies), Laravel’s bootstrap will continue using its default `ComposerAutoloader`, but Jetpack-specific classes won’t load. Implement a fallback mechanism in your service provider to log errors and gracefully degrade functionality.
Are there alternatives to this autoloader for Laravel + WordPress integration?
Yes. For Laravel-WordPress hybrids, consider using WordPress’s native `spl_autoload_register()` with custom PSR-4 mappings or tools like `wp-psr-autoloader`. If you only need Jetpack features, evaluate whether you can replace them with Laravel equivalents (e.g., use Laravel’s `Cache` instead of `Jetpack_Cache`).
How do I ensure this autoloader doesn’t slow down my Laravel application?
Jetpack’s autoloader adds an extra layer to class resolution, which can increase TTFB if not optimized. Minimize impact by loading it only when Jetpack is required (e.g., lazy-load in a service provider) and avoid mixing it with Laravel’s eager loading. Cache autoloader results if possible, though Jetpack’s implementation doesn’t support this natively.
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.
hexters/coinpayment
rjcodes/rjcms
act-training/laravel-permissions-manager
alimarchal/laravel-chart-of-accounts
babenkoivan/elastic-scout-driver
mkwebdesign/filament-watchdog-v5
renatomarinho/laravel-page-speed
zedmagdy/filament-business-hours
renatovdemoura/blade-elements-ui
devgeek/beacon-admin
benjamin-rqt/data-watcher-bundle
atriumphp/atrium
sandermuller/package-boost-laravel
sandermuller/boost-skills
redaxo/core
yusufgenc/filament-api-forge
l3aro/rating-star-for-filament
leek/filament-subtenant-scope
anil/file-picker
broqit/fields-ai