laravel RouteCollection.php 中的 NotFoundHttpException
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/29393241/
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
NotFoundHttpException in RouteCollection.php
提问by Steve
I use Laravel 5!
我使用 Laravel 5!
In my routes.php file I have the following request to check for all admin requests in the URL:
在我的 routes.php 文件中,我有以下请求来检查 URL 中的所有管理请求:
if (Request::is('admin/*'))
{
require __DIR__.'/admin_routes.php';
}
In that case in the corresponding admin_routes.php file it should return the correct controller where I have:
在这种情况下,在相应的 admin_routes.php 文件中,它应该返回正确的控制器,其中我有:
Route::group(['prefix' => 'admin', 'middleware' => 'auth'], function() {
#Admin Dashboard
Route::get('dashboard', 'Admin\DashboardController@index');
});
I cleared already the route cache (php artisan route:clear) , but I get the error message: NotFoundHttpException in RouteCollection.php line 145 . Any ideas what could be wrong? Thank you
我已经清除了路由缓存 (php artisan route:clear) ,但我收到错误消息:NotFoundHttpException in RouteCollection.php line 145 。任何想法可能是错误的?谢谢
回答by Matthias Loibl
Put all your routes in one file, since it is documentation for others aswell. This should be kept as simple as it can be.
将所有路线放在一个文件中,因为它也是其他人的文档。这应该尽可能简单。
Then use Route Groups.
然后使用路由组。
Why would you need to include other files?
为什么需要包含其他文件?