安装好 laravel 后 ,
https://github.com/dingo/api/wiki/Installation
按照 上面的 提示
composer require dingo/api:0.10.*
是直接报错了,
后来 干脆改成了
composer require dingo/api
config/app.php
接着在 providers 配置里面 加上 Dingo\Api\Provider\LaravelServiceProvider::class
如下:
'providers' => [
Dingo\Api\Provider\LaravelServiceProvider::class
]
php artisan vendor:publish --provider="Dingo\Api\Provider\LaravelServiceProvider"
这是后就在 config文件夹下 多出了 一个 api.php 文件
在.env 文件夹下 增加如下
API_PREFIX=api
API_CONDITIONAL_REQUEST=false
API_STRICT=false
API_DEFAULT_FORMAT=json
到此 后面就不知道该怎么做了
下面是 文档,不理解是什么意思了
Authentication Providers
By default only basic authentication is enabled. Authentication is covered in more detail in a later chapter.
You must configure this in a published configuration file or in your bootstrap file.
$app['Dingo\Api\Auth\Auth']->extend('oauth', function ($app) {
return new Dingo\Api\Auth\Provider\JWT($app['Tymon\JWTAuth\JWTAuth']);
});
Throttling / Rate Limiting
By default rate limiting is disabled. You can register your custom throttles with the rate limiter or use the existing authenticated and unauthenticated throttles.
You must configure this in a published configuration file or in your bootstrap file.
$app['Dingo\Api\Http\RateLimit\Handler']->extend(function ($app) {
return new Dingo\Api\Http\RateLimit\Throttle\Authenticated;
});
到 这一步了 该怎么做呢 。,继续 该怎么做呢
有没有 laravel5.1 的 dingo/api 小demo呢
文档有些看不懂呀
Copyright 2014-2026 https://www.php.cn/ All Rights Reserved | php.cn | 湘ICP备2023035733号
dingo提供了Basic的验证方式,当然也可以扩展使用JWT或OAuth方式
可以先跳过鉴权部分,根据wiki创建一些API路由试试,等差不多了再回头调试验证部分