search

Home  >  Q&A  >  body text

laravel dingo/api installation and configuration

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

大家讲道理大家讲道理2809 days ago732

reply all(4)I'll reply

  • 大家讲道理

    大家讲道理2017-05-16 16:57:47

    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

    reply
    0
  • 曾经蜡笔没有小新

    曾经蜡笔没有小新2017-05-16 16:57:47

    $app['DingoApiHttpRateLimitHandler']->extend(function ($app) {
    return new DingoApiHttpRateLimitThrottleAuthenticated;
    });

    Excuse me, which file should this be added to?

    reply
    0
  • 阿神

    阿神2017-05-16 16:57:47

    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

    reply
    0
  • 黄舟

    黄舟2017-05-16 16:57:47

    Here is a demo
    https://github.com/huanghua581/dingo-api-demo

    reply
    0
  • Cancelreply