Pages

03 May, 2024

I'm still unsure how DeferrableProvider improves performance

Referring to the documentation, it states:

Deferring the loading of such a provider will improve the performance of your application, since it is not loaded from the filesystem on every request.

Based on my understanding, consider this example: class RiakServiceProvider extends ServiceProvider implements DeferrableProvider { public function register(): void { $this->app->singleton(Connection::class, function (Application $app) { return new Connection($app['config']['riak']); }); } public function provides(): array { return [Connection::class]; } }

If laravel instantiates the RiakServiceProvider class and calls the register method (regardless of whether I resolve the Connection::class out of the container), how does it optimize the performance of the application? submitted by /u/foremtehan
[link] [comments]

No comments:

Post a Comment

Thanks