Skip to content

Commit

Permalink
Use a more graceful method for re-enabling package auto-discovery
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
caendesilva committed Jan 25, 2023
1 parent ca64f6e commit 32b483a
Showing 1 changed file with 13 additions and 11 deletions.
24 changes: 13 additions & 11 deletions packages/framework/src/Foundation/Application.php
Original file line number Diff line number Diff line change
Expand Up @@ -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';
}
}

1 comment on commit 32b483a

@caendesilva
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Please sign in to comment.