laravel - 如何在 laravel 5.8 中更改默认 api 路由路径
问题描述
我只想将路由/api.php 的路由路径更改为路由/Routes/api.routes.php
这是 RouteServiceProvider.php
class RouteServiceProvider extends ServiceProvider
{
/**
* This namespace is applied to your controller routes.
*
* In addition, it is set as the URL generator's root namespace.
*
* @var string
*/
protected $namespace = 'App\Http\Controllers';
/**
* Define your route model bindings, pattern filters, etc.
*
* @return void
*/
public function boot()
{
//
parent::boot();
}
/**
* Define the routes for the application.
*
* @return void
*/
public function map()
{
$this->mapApiRoutes();
$this->mapWebRoutes();
$this->mapProjectApiRoutes();
//
}
/**
* Define the "web" routes for the application.
*
* These routes all receive session state, CSRF protection, etc.
*
* @return void
*/
protected function mapProjectApiRoutes(){
Route::prefix('api')
->middleware(['api', 'RequestEncrypt', 'ApiKey'])
->namespace('App\Http\Controllers\Api')
->group(base_path('routes/Routes/api.routes.php'));
}
protected function mapWebRoutes()
{
Route::middleware('web')
->namespace($this->namespace)
->group(base_path('routes/web.php'));
}
/**
* Define the "api" routes for the application.
*
* These routes are typically stateless.
*
* @return void
*/
protected function mapApiRoutes()
{
Route::prefix('api')
->middleware('api')
->namespace($this->namespace)
->group(base_path('routes/api.php'));
}
}
这就是我在 RouteServiceProvider.php 中所做的
请检查下图我收到此错误
我正在使用 laravel 5.8 请帮忙。
解决方案
推荐阅读
- android - 修改 AOSP 中的 Poweroff 对话框(按住电源键时出现的菜单)
- npm - 在私有网络上托管 github 版本
- c++ - 在 Windows 10 上编译 MySQL C++ 程序
- python - 这个python代码缩进错误有什么问题?
- django - 如何在使用 django storages 和 django rest framework 将图像上传到 Amazon s3 之前压缩图像?
- logstash - 如何检测并处理 logstash elasticsearch 输出中的错误
- python-2.7 - 为什么我不能从 docx.enum.text 导入 WD_ALIGN_PARAGRAPH?
- c# - 使用 Azure 媒体服务转换将 MP4 转换为 WAV 文件
- recursion - For中的复杂性递归
- ios - 如何在集合视图单元格的一个部分中添加多个数组,该集合视图位于 tableView 单元格内?