安裝好 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呢
文檔有些看不懂呀
laravel有關,先佔個坑,晚上記得再看看
======================
貌似官方文件實在很清晰:
https://github.com/dingo/api/wiki/Creating-API-Endpoints
==============再更新===============
Laravel 5 RESTful API系列影片已錄,有興趣的可以看看
https://laravist.com/series/pe-into-restful-api-with-laravel
$app['DingoApiHttpRateLimitHandler']->extend(function ($app) {
return new DingoApiHttpRateLimitThrottleAuthenticated;
});
請問一下,這個應該加在那個文件裡面呢?
dingo提供了Basic的驗證方式,當然也可以擴充使用JWT或OAuth方式
可以先跳過辨識部分,依照wiki創建一些API路由試試,等差不多了再回頭調試驗證部分
這裡有demo
https://github.com/huanghua581/dingo-api-demo