Dingo 的安装

安装Dingo需要下面的环境:

  • Laravel 5.1 或 lumen 5.1 +
  • php 5.59+

1. 修改composer.json 文件,添加下面的代码:

"require": {
    "dingo/api": "1.0.*@dev"
}

2 .然后根目录下执行composer update

3. Laravel的配置

config/app.php中的providers数组中添加

'providers' => [
    Dingo\Api\Provider\LaravelServiceProvider::class
]

通常情况下,我们都会配置Dingo,我们可以生成自己我们可以修改的dingo配置文件,终端里执行下面的代码

php artisan vendor:publish --provider="Dingo\Api\Provider\LaravelServiceProvider"

4. 门面

Dingo 中自带了两个门面,你可以根据自己的需要添加

//This is a facade for the dispatcher, however, it also provides helper methods for other methods throughout the package.

Dingo\Api\Facade\API

//This is a facade for the API router and can be used to fetch the current route, request, check the current route name, etc.

Dingo\Api\Facade\Route

为了方便,可以为上面的门面设置别名

'aliases' => [
     'APIRoute'  => Dingo\Api\Facade\Route::class,
     'API'       => Dingo\Api\Facade\API::class,
]

猜你喜欢

转载自www.cnblogs.com/wxy0126/p/10738311.html