Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

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

laravel - Why always i clear route and cached route when new created?

I am using Laravel 8 and I am facing issue with route. When I create a route it does not appear in route list after running below command

php artisan route:clear
php artisan route:cache

I get all route. How can i solve it. Why i run these command for new routes?

question from:https://stackoverflow.com/questions/65897588/why-always-i-clear-route-and-cached-route-when-new-created

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

1 Answer

0 votes
by (71.8m points)

From the docs:

Optimizing Route Loading

If you are building a large application with many routes, you should make sure that you are running the route:cache Artisan command during your deployment process:

php artisan route:cache

This command reduces all of your route registrations into a single method call within a cached file, improving the performance of route registration when registering hundreds of routes.

You should only run php artisan route:cache during deployment, while you develop locally you shouldn't cache your routes, otherwise new routes that you create wont be registered until you run php artisan route:clear or php artisan route:cache again.

php artisan route:cache
// clears the route cache and then re caches the routes

php artisan route:clear
// clears the route cache

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...