Skip to content

Commit 83118db

Browse files
committed
apply ruben fix
1 parent 27443ef commit 83118db

File tree

1 file changed

+16
-4
lines changed

1 file changed

+16
-4
lines changed

src/LaravelErrorSolutionsServiceProvider.php

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,8 +23,11 @@ public function configurePackage(Package $package): void
2323
{
2424
$package
2525
->name('error-solutions')
26-
->hasConfigFile()
27-
->hasViews();
26+
->hasConfigFile();
27+
28+
if ($this->canIncludeViews()) {
29+
$package->hasViews();
30+
}
2831
}
2932

3033
public function bootingPackage()
@@ -39,7 +42,7 @@ public function bootingPackage()
3942
return new SolutionProviderRepository($solutionProviders);
4043
});
4144

42-
app()->bind(RunnableSolutionsGuard::class, fn () => new RunnableSolutionsGuard());
45+
app()->bind(RunnableSolutionsGuard::class, fn() => new RunnableSolutionsGuard());
4346

4447
app()->bind(Renderer::class, function () {
4548
$errorRenderer = new HtmlErrorRenderer(
@@ -55,6 +58,15 @@ public function bootingPackage()
5558
);
5659
});
5760

58-
View::prependNamespace('laravel-exceptions-renderer', [__DIR__.'/../resources/views']);
61+
62+
if ($this->canIncludeViews()) {
63+
View::prependNamespace('laravel-exceptions-renderer', [__DIR__ . '/../resources/views']);
64+
}
65+
}
66+
67+
protected function canIncludeViews(): bool
68+
{
69+
// Otherwise php artisan optimize may crash
70+
return config('app.debug') === true;
5971
}
6072
}

0 commit comments

Comments
 (0)