Compile the showcase's views with the showcase off

php artisan view:cache compiles every view in the package's namespace,
the showcase's pages included, but the showcase:: component prefix was
only registered while the showcase was enabled. In production, where it
is off, view:cache failed with "Unable to locate a class or view for
component [showcase::example]" and an application caching its views on
start would not boot. The prefix is now always registered; the routes
still are not.

Co-Authored-By: Claude Opus 5 (1M context) <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_01V9NnLxnPp8vaaurb3Z1MFy
This commit is contained in:
Andreas Reinhold / reini
2026-09-13 17:40:33 +02:00
co-authored by Claude Opus 5
parent 8afe9bac6a
commit 833145403c
2 changed files with 18 additions and 2 deletions
+4 -2
View File
@@ -175,12 +175,14 @@ class LivewireMaterialServiceProvider extends ServiceProvider
*/
protected function registerShowcase(): void
{
// Registered even with the showcase off: `php artisan view:cache` compiles every view in the
// package's namespace, the showcase's pages included, and <x-showcase::…> must resolve there.
Blade::anonymousComponentPath(__DIR__.'/../resources/views/showcase/components', 'showcase');
if (! config('livewire-material.showcase.enabled')) {
return;
}
Blade::anonymousComponentPath(__DIR__.'/../resources/views/showcase/components', 'showcase');
if ($this->app->routesAreCached()) {
return;
}
+14
View File
@@ -71,6 +71,20 @@ it('does not mount the showcase when disabled', function () {
$this->get('/material')->assertNotFound();
});
it('compiles every package view with the showcase off, as view:cache does in production', function () {
rebootWithShowcase(false);
$compiled = sys_get_temp_dir().'/livewire-material-view-cache-'.uniqid();
config(['view.compiled' => $compiled]);
File::ensureDirectoryExists($compiled);
try {
$this->artisan('view:cache')->assertSuccessful();
} finally {
File::deleteDirectory($compiled);
}
});
it('serves a symbol for the icon search', function () {
$this->get('/material/symbols/filled/favorite.svg')
->assertOk()