Dingo 的安装

** 安装Dingo需要下面的环境:**


  • Laravel 5.1 或 lumen 5.1 +
  • php 5.59+

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

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

2 .然后执行

cpmposer 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,
]
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容