onelearningcommunity/laravel-model-explorer
Laravel packages that ship a UI typically serve their compiled frontend assets (JS, CSS, fonts) in one of two ways:
vendor:publish command that copies compiled files into the host application's public/vendor/{package}/ directory. This is the approach taken by Telescope and Horizon.For published assets, consumers must either commit the published files to their own repository or add public/vendor/model-explorer/ to .gitignore. Both paths add friction: committing binary build artefacts bloats the repository history; gitignoring them means the files must be reproduced as part of deployment (an extra setup step that is easy to forget).
Since Model Explorer is a developer-facing tool and not a production-critical service, raw throughput of static file delivery is not a meaningful concern.
Assets are served via a dedicated HTTP route registered by the package service provider:
GET /_model-explorer/assets/{path}
The AssetController resolves the requested path relative to the package's own public/ directory and streams the file with long-lived cache headers (Cache-Control: public, max-age=31536000, immutable). No vendor:publish step is required or exposed for assets.
The asset route:
web middleware — it is intentionally not gated by the Authorize middleware, since assets contain no sensitive data and browsers do not reliably carry session state when fetching script/style resources.realpath() comparison: the resolved path must remain within the package's public/ directory.js, css, woff, woff2, ttf, svg, png, ico, map).Positive:
Negative:
Cache-Control: immutable means a stale cached asset will be served until the browser's cache expires (up to 1 year). This is mitigated by the fact that asset filenames are determined by Vite's build output — breaking changes should produce new filenames via content hashing in future phases.How can I help you explore Laravel packages today?