Home > database >  Error when I delete Blade components classes to make them anonymous
Error when I delete Blade components classes to make them anonymous

Time:02-21

I started my project by creating normal components and now I want to convert some components to anonymous components.

I know that what makes anonymous components anonymous is the absence of the class.

Sample

I have this Blade code:

<x-app-layout>
    <x-slot:header>
        Some heading
        <a href="" title="" >

            <x-icons.plus />

        </a>
    </x-slot:header>
...
</x-app-layout>

When I delete app\View\Components\Icons\Plus.php and revisit the page I get the following error:

ErrorException
include(\path\vendor\composer/../../app/View/Components/Icons/Plus.php): Failed to open stream: No such file or directory

I followed this answer from Laracasts and cleared the cache:

❯ php artisan view:clear
Compiled views cleared!

But the same error persists.

What is very confusing is when I create a new component php .\artisan make:component bruh.plus --view and use it (<x-bruh.plus/>) in the same Blade code all works fine.

CodePudding user response:

I had to dump composers' autoloader.

From now on I'll assume that the correct way to convert normal Blade components to anonymous components is to run:

php artisan view:clear

And

composer dump-autoload
  • Related