According to the documentation for the boot() method in Service Providers: This method is called after all other service providers have been registered but I am finding this to not be the case. Instead, the boot() method is called immediately after the register() method for a given Service Provider.
Create a new Lumen app: Lumen new test-app.
Enable the AppServiceProvider and AuthServiceProvider in bootstrap\app.php.
In each Service Provider, put $this->app['log']->info("Booting AppServiceProvider"); in each boot() and register() methods, replacing Booting with Registering and AppServiceProvider with AuthServiceProvider where applicable. Alternativly, you could just write Booting or Registering.
Run php artisan list.
Look in storage/logs/lumen.log and you should see something like this:
~
[2017-04-19 22:04:50] lumen.INFO: Registering AppServiceProvider
[2017-04-19 22:04:50] lumen.INFO: Booting AppServiceProvider
[2017-04-19 22:04:50] lumen.INFO: Registering AuthServiceProvider
[2017-04-19 22:04:50] lumen.INFO: Booting AuthServiceProvider
~
Attached is a lumen application with the changes already made.
Just ran into the same problem. Seems like this has already been discussed before in https://github.com/laravel/lumen-framework/issues/399. However, this issue was closed early without a concrete answer or solution.
The docs are incorrect. Registering a service provider at runtime will register and boot it, immediately. The docs are referring to registering a service provider at config time, before the app has started.
I hope this distinction makes sense.
@GrahamCampbell - is there a way to register a service provider at config time in Lumen, since there is only a .env file? Or is the only way to do it at runtime?
I just ran into this as well. The Laravel\Lumen\Application::register method makes the existing behaviour pretty damn clear. I'm just not clear of the advantage of doing it this way. Lumen seems to ignore the app.providers configuration key entirely. There's no ProviderRepository or anything in Lumen. I think I'll just switch to Laravel as well.
Can you give an example of "registering a service provider at config time"? Currently, I had to create a separate provider to contain all of my boot logic since the boot method is called immediately following the register method.
@Nais777 that's actually a pretty clever idea.
@Nais777 This has been fixed and merged into lumen master.
Most helpful comment
@Nais777 This has been fixed and merged into lumen master.