Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do we Clear Controller And Model cache in Laravel

I have very simple application in Laravel 5.5.

My Route : Route::resource('books', 'BookController');
My Controller is app/http/Controllers/BookController.php
My Model is app/Book.php

I have similar other modules as well.

INTERESTING PART IS :

My Book controller changes are not being reflected in browser.

I thought of clearing the cache so cleared all caches.

1. Cleared Application Cache > php artisan cache:clear
2. Cleared Route Cache > php artisan route:clear
3. Cleared Configuration Cache > php artisan config:clear 
4. Cleared Compiled Views Cache > php artisan view:clear 

I was not sure which cache was causing the issue so I cleared all. Still my changes are not being reflected in the browser, but when I change the view files, the changes are being reflected.

Any Suggestion please?????

like image 934
Saroj Shrestha Avatar asked Sep 03 '25 06:09

Saroj Shrestha


1 Answers

Finally I guess I have found the solutions. All the files are being cached in this location

/home/project/public_html/vendor/composer/autoload_classmap.php
where project = project name

So if we change the file name, then we need to run the following commands.

php artisan clear-compiled 
composer dump-autoload
php artisan optimize

Since the above bug ruins my past 2 days, so I guess its worth sharing for someone having the same issue or problem.

**Please correct me if above solution can be optimized.

like image 196
Saroj Shrestha Avatar answered Sep 04 '25 18:09

Saroj Shrestha