Closed
Description
Laravel Version
11.0.7
PHP Version
8.3.3
Database Driver & Version
No response
Description
This is a little tricky, but I ran into this issue after upgrading to Laravel 11 and first suspected it was a problem with Blade Heroicons Kit.
In Laravel 11 the optimize
command was extended to cache events and views.
When running optimize on a fresh app with the Heroicons kit it blew up:
➜ heroicons php artisan optimize
INFO Caching framework bootstrap, configuration, and metadata.
config ............................................................................................................................... 7.62ms DONE
events ............................................................................................................................... 0.71ms DONE
routes ............................................................................................................................... 5.56ms DONE
views ............................................................................................................................... 28.61ms FAIL
InvalidArgumentException
Unable to locate a class or view for component [heroicon-s-bars-3].
at vendor/laravel/framework/src/Illuminate/View/Compilers/ComponentTagCompiler.php:311
307▕ if (Str::startsWith($component, 'mail::')) {
308▕ return $component;
309▕ }
310▕
➜ 311▕ throw new InvalidArgumentException(
312▕ "Unable to locate a class or view for component [{$component}]."
313▕ );
314▕ }
315▕
+2 vendor frames
3 [internal]:0
Illuminate\View\Compilers\ComponentTagCompiler::Illuminate\View\Compilers\{closure}(["<x-heroicon-s-bars-3 />", "heroicon-s-bars-3", "", ""])
+7 vendor frames
11 [internal]:0
Illuminate\Foundation\Console\ViewCacheCommand::Illuminate\Foundation\Console\{closure}(Object(Symfony\Component\Finder\SplFileInfo), "/Users/dwight/Sites/heroicons/resources/views/welcome.blade.php")
However, running php artisan view:cache
runs fine.
Through playing with the optimize
command I realised two things:
- If I comment out
config
orroute
caching fromoptimize
then it works fine. Something that happens in theconfig:cache
orroute:cache
command is affecting what happens in theview:cache
command. - The instance of the
BladeCompiler
from the container and the one that is received inside theViewCacheCommand
appear to be different (and the second doesn't have the Heroicon aliases available)
Steps To Reproduce
laravel new heroicons
cd heroicons
composer require blade-ui-kit/blade-heroicons
Add an icon to the welcome page: <x-heroicon-s-bars-3 />