A singleton bound lazily and resolved eagerly by a line in the same provider, four years after somebody added it.
public function register(): void
{
$this->app->singleton(FeatureFlags::class, fn () => new FeatureFlags(
$this->app->make(Repository::class)->all(), // a query
));
}
public function boot(): void
{
View::share('flags', $this->app->make(FeatureFlags::class));
// ↑ resolves it on every request, including the API
}
Sharing a value with every view is the eager resolution, and the API requests that never render a view were paying for it anyway. Replacing the share with a view composer scoped to the layouts that use it moved the query to the requests that need it, which is 12% of them.