2.1. 安装

未匹配的标注
本文档最新版为 2.0.0,旧版本可能放弃维护,推荐阅读最新版!

Requirements & Versions

It is very important to understand which version of Dingo to use, and even more so to understand what is supported and what is not. If the version of dingo you are using is not supported, then please update it, and if necessary your version of Laravel - do NOT raise support tickets for unsupported versions!

In any case, there is very limited support for Lumen. If you are starting a new project we do not recommend you use Lumen. If you have an opportunity to move to Laravel - we recommend you do so!

Dingo Version Laravel Version Minimum PHP version Supported?
1.x.x Pre 5.6 No
2.x.x 5.6 - 6.x PHP 7.1 - 7.2 Not for long
3.x.x 7.x PHP 7.2.5 Yes

You must then modify your composer.json file and run composer update to include the latest version of the package in your project.

"require": {
    "dingo/api": "^3.0.0"
}

You may need to set your minimum-stability to dev.

Once the package is installed the next step is dependant on which framework you're using.

Laravel

If you'd like to make configuration changes in the configuration file you can publish it with the following Artisan command (otherwise, this step is not needed):

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

Lumen

Open bootstrap/app.php and register the required service provider.

$app->register(Dingo\Api\Provider\LumenServiceProvider::class);

Facades

There are two facades shipped with the package. You can add either of them should you wish.

Dingo\Api\Facade\API

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

Dingo\Api\Facade\Route

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

Configuration →

本文章首发在 LearnKu.com 网站上。

上一篇 下一篇
《L05 电商实战》
从零开发一个电商项目,功能包括电商后台、商品 & SKU 管理、购物车、订单管理、支付宝支付、微信支付、订单退款流程、优惠券等
《L03 构架 API 服务器》
你将学到如 RESTFul 设计风格、PostMan 的使用、OAuth 流程,JWT 概念及使用 和 API 开发相关的进阶知识。
讨论数量: 1
发起讨论 只看当前版本


Debuff
Laravel 6.x + dingo 2.4 依赖配置
5 个点赞 | 4 个回复 | 分享 | 课程版本 2.0.0