Skip to content

Commit 47e7b6f

Browse files
authored
Fix "unable to locate" error. (#276)
1 parent e2cf26e commit 47e7b6f

1 file changed

Lines changed: 12 additions & 0 deletions

File tree

src/BladeIconsServiceProvider.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,18 @@ private function registerFactory(): void
6565
$this->callAfterResolving(ViewFactory::class, function ($view, Application $app) {
6666
$app->make(Factory::class)->registerComponents();
6767
});
68+
69+
// Ensure components are registered during console commands (like optimize)
70+
// that may compile views before ViewFactory is resolved
71+
if ($this->app->runningInConsole() && ! $this->app->environment('testing')) {
72+
$this->app->booted(function (Application $app) {
73+
try {
74+
$app->make(Factory::class)->registerComponents();
75+
} catch (\Exception $e) {
76+
// Silently fail if factory isn't ready yet
77+
}
78+
});
79+
}
6880
}
6981

7082
private function registerManifest(): void

0 commit comments

Comments
 (0)