Search code examples
phplaravellaravel-5laravel-artisanlaravel-5.7

Cache Error Class does not exist - Laravel 5.7


I can't list my route on Laravel 5.7

I tried php artisan route:list I got

enter image description here

I searched in my entire application, I don't see this file is being imported.

enter image description here

I've also tried

└── 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] 
└──

Solution

  • It happens due to the cache issue in Laravel. You must have had CommentController once, at some point in your project which you have deleted and recreated, now the project doesn't find it even if you have it again. In any case, running folllowing commands should fix your issue:

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

    See for explanation: https://www.youtube.com/watch?v=Q1ynDMC8UGg