gpt4 book ai didi

Laravel 5.3 和 5.4 自定义路由文件

转载 作者:行者123 更新时间:2023-12-04 04:29:48 25 4
gpt4 key购买 nike

根据 Laravel 文档,在路由部分,位于路由目录中的文件由框架自动加载。

All Laravel routes are defined in your route files, which are located in the routes directory. These files are automatically loaded by the framework.

因此,我尝试在此目录中创建另一个名为 auth.php 的文件来处理我的自定义身份验证路由。但是,该文件中定义的路由并未加载。

是否可以使用这种方法,或者我需要注册一个服务提供商来加载自定义路由文件?

最佳答案

您需要在RouteServiceProvider.php中映射路由,请查看网络路由示例。

   /**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapWebRoutes()
{
Route::group([
'middleware' => 'web',
'namespace' => $this->namespace,
], function ($router) {
require base_path('routes/web.php');
});
}

关于Laravel 5.3 和 5.4 自定义路由文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42390913/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com