Target class [view] does not exist. in Container.php
Asked Answered
F

5

8

I have a problem with laravel and I don't know how to fix it for now. Actually I don't know how I face this problem, but will try to explain you what I did and what I tried for now to fix the problem.

I tried composer update and this problem occured. Now I can not type any command like php artisan make:livewire name or even php artisan --version, everytime when I try to execute commands I receive this error in console

In Container.php line 811:
                                       
  Target class [view] does not exist.  
                                       

In Container.php line 809:
                             
  Class view does not exist 

Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1 
                             

Also the information from the log file

[previous exception] [object] (ReflectionException(code: -1): Class view does not exist at /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php:809)
[stacktrace]
#0 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(809): ReflectionClass->__construct()
#1 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(691): Illuminate\\Container\\Container->build()
#2 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(796): Illuminate\\Container\\Container->resolve()
#3 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(637): Illuminate\\Foundation\\Application->resolve()
#4 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(781): Illuminate\\Container\\Container->make()
#5 /var/www/vendor/laravel/framework/src/Illuminate/Container/Container.php(1284): Illuminate\\Foundation\\Application->make()
#6 /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(198): Illuminate\\Container\\Container->offsetGet()
#7 /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(166): Illuminate\\Support\\Facades\\Facade::resolveFacadeInstance()
#8 /var/www/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php(255): Illuminate\\Support\\Facades\\Facade::getFacadeRoot()
#9 /var/www/vendor/beyondcode/helo-laravel/src/HeloLaravelServiceProvider.php(41): Illuminate\\Support\\Facades\\Facade::__callStatic()
#10 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(627): BeyondCode\\HeloLaravel\\HeloLaravelServiceProvider->register()
#11 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/ProviderRepository.php(75): Illuminate\\Foundation\\Application->register()
#12 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(604): Illuminate\\Foundation\\ProviderRepository->load()
#13 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Bootstrap/RegisterProviders.php(17): Illuminate\\Foundation\\Application->registerConfiguredProviders()
#14 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Application.php(230): Illuminate\\Foundation\\Bootstrap\\RegisterProviders->bootstrap()
#15 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(310): Illuminate\\Foundation\\Application->bootstrapWith()
#16 /var/www/vendor/laravel/framework/src/Illuminate/Foundation/Console/Kernel.php(127): Illuminate\\Foundation\\Console\\Kernel->bootstrap()
#17 /var/www/artisan(37): Illuminate\\Foundation\\Console\\Kernel->handle()
#18 {main}
"} 

Solutions I have been tried till now:

1.Delete vendor folder and type composer install again but at the final stage I received this error again.

2.Delete vendor and composer.lock still without success.

3.Cleaned boostrap/cache/*.php folder and run commands again, but it not worked again.

So any advice how to fix this problem will be appreciated. Laravel Version: 7

Flowerless answered 20/11, 2020 at 7:53 Comment(8)
add -vvv to any command you run to see if you can get a more verbose error message, perhaps a stacktraceWard
Try run: composer dump-autoloadRetroaction
@HarpalSingh already tried without success, still received the same error . Lagbox I did not receive more information from stacktrace after added -vvvFlowerless
what did you do to cause this in the first place?Ward
I tried to install one package and I received this error, and from then I'm not able to do anythingFlowerless
Please share more details about the problem. Can you reset your project to a state where this error does not occur? If yes, please add the differences to your post, along with your debugging attemptsMosira
what package and what does "try" mean ... what happened?Ward
I have been tried to install this package miljar/php-exif, but I don't think it's matters. Also I can provide and one more error message Script @php artisan package:discover --ansi handling the post-autoload-dump event returned with error code 1Flowerless
F
4

The whole problem was that, another developer had commented line Illuminate\View\ViewServiceProvider::class, inside config/app.php providers

Flowerless answered 20/11, 2020 at 13:13 Comment(1)
Wow, you just saved me hours of debug!Decalescence
G
5

For me this error occurred after having executed php artisan optimize:clear.

All I had to do to fix it was to execute php artisan view:cache

Golgotha answered 9/6, 2022 at 10:42 Comment(2)
In my case All I had to do was to execute php artisan optimizeCallisthenics
php artisan view:cache worksPolygnotus
F
4

The whole problem was that, another developer had commented line Illuminate\View\ViewServiceProvider::class, inside config/app.php providers

Flowerless answered 20/11, 2020 at 13:13 Comment(1)
Wow, you just saved me hours of debug!Decalescence
C
0

One can also run composer install and it could also fix some versions of this error.

Cofferdam answered 23/4, 2021 at 11:30 Comment(0)
P
0

I solve this problem in my app (Laravel 8, php 7.4 online server) following the steps below:

  1. access my server over ssh

  2. execute this command for the installer composer:
    curl -sS https://getcomposer.org/installer | php

  3. change the name of composer.phar for composer. Follow the stpes below: mkdir ~/bin mv ~/composer.phar ~/bin/composer

  4. now execute this command for apache PHP export PATH=$PATH:/var/www/bin echo 'export PATH=$PATH:/var/www/bin' >> ~/.bashrc

Now test using the command composer about

Perfect! Now do you need delete your folder VENDOR, and run the command below : composer update Voila! try access you application again

Pedestrianize answered 4/9, 2022 at 16:32 Comment(0)
S
-1

My project was missing .htaccess file on /public folder. I added it and it worked.

Shortcircuit answered 2/8, 2024 at 6:53 Comment(0)

© 2022 - 2025 — McMap. All rights reserved.