laravel dingo/api installation and configuration
大家讲道理
大家讲道理 2017-05-16 16:55:47
0
4
659

After installing laravel,

Start installing laravel dingo/api

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

Open config/app.php

Then add Dingo\Api\Provider\LaravelServiceProvider::class in the providers

configuration

as follows:

'providers' => [
    Dingo\Api\Provider\LaravelServiceProvider::class
]

Write to config/api.php

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

After this, there is an additional api.php file in the config folder

Configuration .env file

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

大家讲道理
大家讲道理

光阴似箭催人老,日月如移越少年。

reply all(4)
大家讲道理

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

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template
About us Disclaimer Sitemap
php.cn:Public welfare online PHP training,Help PHP learners grow quickly!