Laravel 5 缓存路由未更新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/29321252/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-14 11:14:53  来源:igfitidea点击:

Laravel 5 Cached Routes not updating

phplaravellaravel-5laravel-routing

提问by guidsen

I've cached my Laravel 5 routes by doing php artisan route:cache. This went succesfull for quite a while and when I changed a route is could cache them again and it would all work like it should.

我通过执行缓存了我的 Laravel 5 路线php artisan route:cache。这成功了很长一段时间,当我更改路线时,可以再次缓存它们,并且一切都会正常工作。

The problem is that I've moved some routes to another route group and it seems that they won't be cached for some reason.

问题是我已经将一些路由移动到另一个路由组,并且由于某种原因它们似乎不会被缓存。

I've tried to cache them again but it didn't work. I've also tried php artisan cache:clearbut still not working.

我试过再次缓存它们,但没有用。我也试过了,php artisan cache:clear但还是不行。

Routes.php changes:

Routes.php 更改:

Route::group(['prefix' => 'api', 'middleware' => 'auth'], function () {
   Route::get('invites', 'InvitationController@get');
   Route::get('invites/check', 'InvitationController@check');
});

Changed to:

变成:

Route::group(['prefix' => 'api'], function () {
   Route::post('auth', 'Auth\AuthController@authenticate');
   Route::get('invites', 'InvitationController@get');
   Route::get('invites/check', 'InvitationController@check');
});

As you can see I've moved those invitationroutes to the Route group without the AuthenticateMiddleware. When I cached the routes again, it still does execute the AuthMiddleware even when they are moved out of the group..

如您所见,我已将这些invitation路由移至没有Authenticate中间件的 Route 组。当我再次缓存路由时,Auth即使它们被移出组,它仍然会执行中间件。

回答by Goopil

The right syntaxe to remove cached route in laravel 5.* is

在 laravel 5.* 中删除缓存路由的正确语法是

php artisan route:clear

Regards

问候