modera/mjr-cache-aware-class-loader
A cache-aware PHP class loader for Laravel that speeds up autoloading by caching class lookups and refreshing them when files change. A drop-in replacement for Composer's autoloader aimed at cutting filesystem overhead in larger applications.
Read this before you install anything: the package name and the description lie. The description calls it a "Laravel/PHP class loader" and shows a plain composer require. The actual source is a Symfony 2.x/3.x bundle — ModeraMjrCacheAwareClassLoaderBundle — that decorates the MJR/ExtJS class-loader HTTP endpoint. It has no laravel/framework constraint, no service provider, no config/ publishable config, no facade. It was split from a monorepo, last tagged 2016-06-10, and the repo is read-only. There is no "day-to-day" in a Laravel app for this package; the honest first step is deciding whether you're evaluating it at all.
If you're still here, your realistic first three steps are:
Confirm the framework mismatch before wasting a sprint. Run:
composer show -a modera/mjr-cache-aware-class-loader
Look at the type (expect symfony-bundle), require (expect symfony/*, not illuminate/*), and the tags. If you see Symfony constraints, stop — this is not installable in a Laravel app without pulling in a second framework's idioms for one asset concern.
If the target is actually a legacy Symfony/MJR app, look in this order:
Resources/config/routing.xml — the route Ext.Loader must be pointed at.Controller/ — the action that computes ETag/Last-Modified and streams the class file.DependencyInjection/Configuration.php — whether any TTL/private/public knobs exist.DependencyInjection/ — the compiler pass or service decorator that replaces MJR's stock loader.Register in app/AppKernel.php and import the routing as a Symfony bundle — not as a Laravel service provider:
new Modera\MjrCacheAwareClassLoaderBundle\ModeraMjrCacheAwareClassLoaderBundle(),
If you're on Laravel (the realistic case), your first use case is a 30-minute reference read, not an install. The transferable idea is: a class/asset endpoint should return validators (ETag/Last-Modified) and Cache-Control, and support 304 so repeat loads skip the origin. Implement that idea in Laravel middleware over your own asset route — see Implementation Patterns — rather than trying to vendor a dead Symfony bundle.
Sanity check if you did get it running somewhere legacy:
bin/console debug:router | grep -i mjr
curl -sI 'https://app.local/mjr/class-loader/load?className=Modera.Foo' # expect ETag, Last-Modified, Cache-Control
curl -sI -H 'If-None-Match: "<etag>"' 'https://app.local/mjr/class-loader/load?className=Modera.Foo' # expect 304, no body
Since you will not be use-ing this as a package in Laravel, the useful patterns are what to borrow and how to wire the equivalent in a modern stack.
ETag + Last-Modified + long Cache-Control → honour If-None-Match/If-Modified-Since with an empty 304. That is ~20 lines of Laravel middleware over your own route; you do not need the bundle to get it.
Route::get('/mjr/class-loader/{class}', function (string $class) {
$path = base_path('vendor/mjr/'.str_replace('.', '/', $class).'.js');
abort_unless(is_file($path), 404);
return response()->file($path, [
'Cache-Control' => 'private, max-age=31536000, immutable',
]); // Symfony's BinaryFileResponse sets ETag/Last-Modified and 304 for you
});
Ext.define. In Laravel, append an assets_version-style token (deploy ID or content hash) to the Ext.Loader path, or purge your CDN/Varnish on release. max-age alone is not an invalidation strategy.HttpCache (Symfony) / your app behind Varnish/CDN, or you're paying for an ETag on every load and getting nothing back.Ext.Loader disableCaching: true (which appends _dc=…) in local/dev and skip the long max-age there. _dc already defeats caching; a stale JS during development is a debugging tax with no upside.Ext.Loader requests. That confines the bundle's surface to "compute validators + stream the file."kernel.response listener (or Laravel Terminate/middleware) if you want templates/CSS to share the caching policy — the bundle only covers the class-loader endpoint.composer require in the description are misleading; the artifact is a Symfony bundle. If you composer require this into a Laravel app you get either a resolver failure or dead weight plus stray Symfony dependencies. Treat the description as aspirational, not accurate."dev-master" or a specific tag) and expect to fork and own it permanently if you insist on adopting — ContainerAware inheritance and untyped Controller::*Action signatures are the usual PHP 8 / Symfony 5+ breakages.?className=… becomes a filesystem path. Verify the action normalizes and confines it (realpath + prefix check), not naive str_replace('.', '/'). If you inherit this, audit and add the guard yourself; there is no maintainer to file a CVE with.private vs public. A public Cache-Control on an authenticated class-loader route leaks class source through any intermediary proxy. Confirm the responses are private or the route is restricted to a trusted network.Last-Modified for identical content, so clients bounce and re-download. Use a deploy ID / content hash as the validator.$response->setNotModified(); appending a body to a 304 breaks some proxies and Ext's loader.Cache-Control. Verify with curl -I against the real stack, not just a controller unit test.Ext.Loader.setPath(...) / the Symfony-side namespace registry before blaming the cache bundle.How can I help you explore Laravel packages today?