0033: Laravel's package list in the project
On this page
Status: accepted. It changes where 0011 keeps the Laravel manifest; dumps still come through the prepend file.
Context
Short Leash adds its service provider to Laravel apps by pointing APP_PACKAGES_CACHE at a package list it builds (0011). That list lived in Short Leash's own folder, one per project. Laravel treats a path as absolute only when it starts with / or \, so on Windows C:\Users\… landed under the project and php artisan package:discover failed, which ended new Laravel sites and composer install. A path relative to the project can't cross drives, and PHP can't open \\?\C:\… paths. And with the variable set, package:discover rebuilt Short Leash's list instead of the project's bootstrap/cache/packages.php, which went stale for when Laravel details is off.
Decision
- Short Leash writes its list to
bootstrap/cache/leash-packages.phpin the project and setsAPP_PACKAGES_CACHEto that relative path. Laravel puts it under the project on every OS and drive. - The file starts with a
// Short Leash:line holding the modification times ofvendor/composer/installed.jsonandcomposer.json. Short Leash rebuilds it when they change, or when Laravel has written over it. php artisan package:discoverruns without Short Leash's list, so it builds the project's ownpackages.phpas it would without Short Leash.- A project whose
bootstrap/cacheisn't writable is left alone. - The old lists in Short Leash's
generated/php/laravelfolder are removed when Short Leash starts.
Consequences
Laravel details works on Windows, on any drive, and the project's own package list stays current. Short Leash now writes one file into Laravel projects: a cache file in the folder Laravel keeps its caches in, which Laravel's .gitignore there excludes and php artisan clear-compiled removes (Short Leash builds it again). composer.json, config/app.php and every other project file are still never changed.