且构网

分享程序员开发的那些事...
且构网 - 分享程序员编程开发的那些事

如何在 Laravel 5.3 中使用 API 路由

更新时间:2023-02-17 10:00:32

由您调用

http://localhost:8080/api/test
                      ^^^

如果您查看 app/Providers/RouteServiceProvider.php 您会看到默认情况下它为 API 路由设置了 api 前缀,如果您愿意,当然可以更改.

If you look in app/Providers/RouteServiceProvider.php you'd see that by default it sets the api prefix for API routes, which you can change of course if you want to.

protected function mapApiRoutes()
{
    Route::group([
        'middleware' => 'api',
        'namespace' => $this->namespace,
        'prefix' => 'api',
    ], function ($router) {
        require base_path('routes/api.php');
    });
}