Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel 5.5 autodiscovery not registering

I'm installing the spatie\laravel-backup package. According to the instructions, I just need to composer require spatie\laravel-backup and the package should be recognized and auto-installed. It looks like this is happening:

Generating optimized autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: spatie/laravel-backup

But looking in /config/app.php there's no mention of backup anywhere in the providers, and the expected /config/backup.php configuration file isn't found.

Are there any additional commands I need to issue to complete the auto-discovery?

like image 526
user101289 Avatar asked Oct 22 '17 18:10

user101289


2 Answers

But looking in /config/app.php there's no mention of backup anywhere in the providers, and the expected /config/backup.php configuration file isn't found.

Laravel 5.5 does not modify your configuration files when it discovers packages. We only need to add service provider entries and facade aliases to config/app.php when manually registering a package's services.

Package discovery works by reading vendor/composer/installed.json to find autoloadable packages. It then saves a cached manifest file that the application reads when it boots to load the package providers and aliases (typically in bootstrap/cache/packages.php).

We can reload this cached package manifest file by running:

php artisan package:discover

Package discovery does not publish a package's assets, such as the configuration file you describe. The developer must explicitly run the vendor:publish command:

php artisan vendor:publish --provider='Spatie\Backup\BackupServiceProvider'

This limitation is by design. Laravel has no way to know if the developer wants to publish a package's components, because, in many cases, packages provide optional components and the developer can choose which ones to publish.

like image 161
Cy Rossignol Avatar answered Nov 04 '22 18:11

Cy Rossignol


Run php artisan vendor:publish to publish the config file.

like image 1
Raza Mehdi Avatar answered Nov 04 '22 18:11

Raza Mehdi