Ad

Error When I Delete Blade Components Classes To Make Them Anonymous

- 1 answer

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 componentsanonymous is the absence of the class.

Sample

I have this Blade code:

<x-app-layout>
    <x-slot:header>
        Some heading
        <a href="" title="" class="inline-block bg-blue-400 hover:bg-blue-500 text-white mx-1 p-2 rounded-full">

            <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.

Ad

Answer

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
Ad
source: stackoverflow.com
Ad