如何更改laravel 5.8中的默认api路由路径

如何更改laravel 5.8中的默认api路由路径,laravel,api,routes,Laravel,Api,Routes,我只想将路由/api.php的api的路由路径更改为路由/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 gen

我只想将路由/api.php的api的路由路径更改为路由/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中所做的

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'));
    }
}
请检查下面的图片,我得到了这个错误

我用的是拉威尔5.8
请提供帮助。

找出错误消息中的错误,该错误消息将包括行号并修复此错误。此错误我正在获取BadMethodCallException:Method Illumb\Routing\ResponseFactory::api不存在。在文件D:\XAMPP\htdocs\laravelFresh5.8\vendor\laravel\framework\src\illumb\Support\Traits\Macroable.php的第104行中,查看stacktrace,可能是其中的下一步(如果在找到代码之前不继续进行跟踪),它将具有您尝试使用不存在的方法的行号,
ResponseFactory
没有名为
api
的方法找出错误消息中的错误,该错误消息将包括行号并修复此错误我正在获取BadMethodCallException:method Illumb\Routing\ResponseFactory::api不存在。在文件D:\XAMPP\htdocs\laravelFresh5.8\vendor\laravel\framework\src\illumb\Support\Traits\Macroable.php的第104行中,查看stacktrace,可能是其中的下一步(如果在找到代码之前不继续进行跟踪),它将具有您尝试使用不存在的方法的行号,
ResponseFactory
没有名为
api