缓存错误 Class 不存在 - Laravel 5.7

Cache Error Class does not exist - Laravel 5.7

我无法在 Laravel 5.7

上列出我的路线

我试过了php artisan route:list我得到了

我在整个应用程序中进行了搜索,但没有看到正在导入此文件。

我也试过了

└── composer dumpauto                                                                                  
Do not run Composer as root/super user! See https://getcomposer.org/root for details
Generating autoload files
> Illuminate\Foundation\ComposerScripts::postAutoloadDump
> @php artisan package:discover
Discovered Package: nesbot/carbon
Discovered Package: laravel/slack-notification-channel
Discovered Package: laravel/nexmo-notification-channel
Discovered Package: laravelcollective/remote
Discovered Package: htmlmin/htmlmin
Discovered Package: intervention/image
Discovered Package: laravelcollective/html
Package manifest generated successfully.
You have new mail in /var/mail/root
┌──[root@bheng]──[/home/forge/bheng] 
└── php artisan route:list                                                                                   

In Container.php line 779:

  Class App\Http\Controllers\CommentController does not exist  


┌──[root@bheng]──[/home/forge/bheng] 
└── php artisan cache:clear                                                                             
Application cache cleared!
┌──[root@bheng]──[/home/forge/bheng] 
└── php artisan route:list                                                                                  

In Container.php line 779:

  Class App\Http\Controllers\CommentController does not exist  


┌──[root@bheng]──[/home/forge/bheng] 
└──

检查你的路线(web.php),找到 CommentController

它应该在那里,删除它

问题是您在 web.php 下调用 CommentController, 但是您的控制器文件夹中没有 CommentController

这是由于 Laravel 中的缓存问题造成的。你一定有过一次 CommentController,在你删除并重新创建的项目中的某个点,现在即使你再次拥有它,项目也找不到它。无论如何,运行 以下命令应该可以解决您的问题:

php artisan view:clear
php artisan route:clear
php artisan cache:clear
php artisan config:clear
composer dump-autoload

解释见:https://www.youtube.com/watch?v=Q1ynDMC8UGg