首页 > laravel dingo/api 安装与配置

laravel dingo/api 安装与配置

安装好 laravel 后 ,

开始 安装 laravel dingo/api

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
]

写入 config/api.php

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

这是后就在 config文件夹下 多出了 一个 api.php 文件

配置 .env 文件

在.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呢

文档有些看不懂呀


这里有个demo
https://github.com/huanghua581/dingo-api-demo


laravel有关,先占个坑,晚上记得再看看

======================

貌似官方文档实在很清晰:

https://github.com/dingo/api/wiki/Creating-API-Endpoints

==============再次更新===============

Laravel 5 RESTful API系列视频已录,感兴趣的可以看看

https://laravist.com/series/dive-into-restful-api-with-laravel


dingo提供了Basic的验证方式,当然也可以扩展使用JWT或OAuth方式
可以先跳过鉴权部分,根据wiki创建一些API路由试试,等差不多了再回头调试验证部分


$app['Dingo\Api\Http\RateLimit\Handler']->extend(function ($app) {
return new Dingo\Api\Http\RateLimit\Throttle\Authenticated;
});

请问一下,这个应该加在那个文件里面呢?

【热门文章】
【热门文章】