Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
380 views
in Technique[技术] by (71.8m points)

php - Clear all cache in Laravel with artisan

I have following error every time I try to clear cache in Laravel 7.

Class 'AppProvidersTranslationServiceProvider' not found

I removed my provider but it still exists in cache. I don't want to remove manually directory /bootrstrap/cache. Does exist any artisan command which will take care of flushing all cache without any error?

I have already tried without any effect:

artisan config:cache
artisan config:clear
artisan cache:clear
artisan optimize

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

Proper way

Check if /projectroot/app/Providers/TranslationServiceProvider.php class exists with the minimum content of:

<?php

namespace AppProviders;

class TranslationServiceProvider {}

Create this file if you don't have it. Then run php artisan config:cache to check if the error has been gone.

Hacky way

Open bootstrap/services.php file and search for AppProvidersTranslationServiceProvider and remove the full line where you see it.

Finally after both ways

Go to config/app.php, find the line AppProvidersTranslationServiceProvider.php in providers and aliases arrays, where it exists and remove them.

Then run php artisan config:cache again to cache the services without having that reference. If everything goes correct, you may safely delete the file which you've created at the first step (if you've used the proper method).


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...