After installing laravel,
https://github.com/dingo/api/wiki/Installation
Follow the tips above
composer require dingo/api:0.10.*
is an error report directly,
Later, it was simply changed to
composer require dingo/api
config/app.php
Then add Dingo\Api\Provider\LaravelServiceProvider::class
in the
providers
as follows:
'providers' => [
Dingo\Api\Provider\LaravelServiceProvider::class
]
php artisan vendor:publish --provider="Dingo\Api\Provider\LaravelServiceProvider"
After this, there is an additional api.php file in the config folder
Add the following in the .env folder
API_PREFIX=api
API_CONDITIONAL_REQUEST=false
API_STRICT=false
API_DEFAULT_FORMAT=json
Now I don’t know what to do next
The following is the document, I don’t understand what it means
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;
});
Now that we have reached this step, what should we do? , continue what to do
Is there a small demo of dingo/api for laravel5.1?
I can’t understand the document
Laravel related, take a look first, remember to check it out tonight
======================
It seems that the official document is really clear:
https://github.com/dingo/api/wiki/Creating-API-Endpoints
==============Update again================
Laravel 5 RESTful API series video has been recorded, you can watch it if you are interested
https://laravist.com/series/pe-into-restful-api-with-laravel
$app['DingoApiHttpRateLimitHandler']->extend(function ($app) {
return new DingoApiHttpRateLimitThrottleAuthenticated;
});
Excuse me, which file should this be added to?
dingo provides Basic verification method, of course it can also be extended to use JWT or OAuth method
You can skip the authentication part first, try to create some API routes according to the wiki, and then go back to debug the verification part when you are almost done
Here is a demo
https://github.com/huanghua581/dingo-api-demo