From 32b483ab95487e7aa0af92828f85fbd7cc58d350 Mon Sep 17 00:00:00 2001 From: Caen De Silva Date: Wed, 25 Jan 2023 21:38:48 +0100 Subject: [PATCH] Use a more graceful method for re-enabling package auto-discovery Laravel Zero disables auto-discovery, but we want to use it, so we'll call the grandparent's method instead of the parent's, instead of the previous behaviour where Laravel enables it, Zero disables it, and we disable it again. What this change does is letting Laravel handle it, but with our custom cache path. --- .../framework/src/Foundation/Application.php | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/packages/framework/src/Foundation/Application.php b/packages/framework/src/Foundation/Application.php index 5edac65e861..0389615fafc 100644 --- a/packages/framework/src/Foundation/Application.php +++ b/packages/framework/src/Foundation/Application.php @@ -17,17 +17,19 @@ class Application extends \LaravelZero\Framework\Application */ protected function registerBaseBindings(): void { - parent::registerBaseBindings(); + // Laravel Zero disables auto-discovery, but we want to use it, + // so we'll call the grandparent's method instead of the parent's. + \Illuminate\Foundation\Application::registerBaseBindings(); + } - /* - * Enable package auto-discovery. - */ - $this->app->singleton(PackageManifest::class, function (): PackageManifest { - return new PackageManifest( - new Filesystem, - $this->basePath(), - $this->basePath('storage/framework/cache/packages.php') - ); - }); + /** + * Get the path to the cached packages.php file. + * + * @return string + */ + public function getCachedPackagesPath() + { + // Since we have a custom path for the cache directory, we need to return it here. + return 'storage/framework/cache/packages.php'; } }