Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

AleksandrP's avatar

Class "Vite" not found PHP 8.1.9 Laravel 9.27.0

after the update, such an error appeared when trying to use the Vite::asset method in blade templates. Vitek is working, everything is fine. Please help me with advice on what to do?

0 likes
9 replies
Sinnbeck's avatar

Can you show the code that is throwing the error?

AleksandrP's avatar

@Sinnbeck <img src="{{ Vite::asset('resources/assets/media/images/default.png') }}"> file home.blade.php

Sinnbeck's avatar

@AleksandrP I cannot recreate the error with the same version of laravel. Can you try php artisan optimize:clear and composer update?

AleksandrP's avatar
AleksandrP
OP
Best Answer
Level 1

resolved. I forgot to update the file config/app.php

AleksandrP's avatar

@Sinnbeck

  1. add use Illuminate\Support\Facades\Facade;
  2. add:
'aliases' => Facade::defaultAliases()->merge([
        // 'ExampleClass' => App\Example\ExampleClass::class,
    ])->toArray(),  
1 like
myurtsev's avatar

Just adding 'Vite' => Illuminate\Support\Facades\Vite::class, to the array of class aliases will suffice.

3 likes

Please or to participate in this conversation.