Convert Figma logo to code with AI

dingo logoapi

A RESTful API package for the Laravel and Lumen frameworks.

9,325
1,251
9,325
186

Top Related Projects

78,107

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.

29,705

The Symfony PHP framework

8,678

CakePHP: The Rapid Development Framework for PHP - Official Repository

14,235

Yii 2: The Fast, Secure and Professional PHP Framework

11,964

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

64,773

Fast, unopinionated, minimalist web framework for node.

Quick Overview

Dingo API is a powerful and flexible API package for Laravel, designed to simplify the process of building RESTful APIs. It provides a set of tools and conventions that help developers create robust, scalable, and well-structured APIs with ease, while maintaining compatibility with various API standards and best practices.

Pros

  • Simplifies API development in Laravel with built-in features like versioning, rate limiting, and authentication
  • Offers flexible response transformers for easy data formatting and manipulation
  • Provides comprehensive documentation and active community support
  • Integrates well with other Laravel packages and tools

Cons

  • Learning curve for developers new to the package or API development in general
  • May introduce unnecessary complexity for simple API projects
  • Some users report occasional compatibility issues with certain Laravel versions
  • Limited built-in support for non-RESTful API architectures

Code Examples

  1. Basic API route definition:
$api = app('Dingo\Api\Routing\Router');

$api->version('v1', function ($api) {
    $api->get('users', 'App\Http\Controllers\UserController@index');
    $api->post('users', 'App\Http\Controllers\UserController@store');
});
  1. Using API response transformers:
use Dingo\Api\Routing\Helpers;

class UserController extends Controller
{
    use Helpers;

    public function show($id)
    {
        $user = User::findOrFail($id);
        return $this->response->item($user, new UserTransformer);
    }
}
  1. Implementing API authentication:
$api->version('v1', ['middleware' => 'api.auth'], function ($api) {
    $api->get('user', function () {
        return Auth::guard('api')->user();
    });
});

Getting Started

  1. Install Dingo API via Composer:

    composer require dingo/api
    
  2. Add the service provider to config/app.php:

    Dingo\Api\Provider\LaravelServiceProvider::class,
    
  3. Publish the configuration file:

    php artisan vendor:publish --provider="Dingo\Api\Provider\LaravelServiceProvider"
    
  4. Configure your API in the .env file:

    API_STANDARDS_TREE=vnd
    API_SUBTYPE=myapp
    API_PREFIX=api
    API_VERSION=v1
    API_DEBUG=true
    
  5. Start building your API routes in routes/api.php:

    $api = app('Dingo\Api\Routing\Router');
    
    $api->version('v1', function ($api) {
        $api->get('hello', function () {
            return ['message' => 'Hello, World!'];
        });
    });
    

Competitor Comparisons

78,107

Laravel is a web application framework with expressive, elegant syntax. We’ve already laid the foundation for your next big idea — freeing you to create without sweating the small things.

Pros of Laravel

  • Full-featured web application framework with built-in tools for routing, authentication, and database management
  • Extensive documentation and large community support
  • Elegant syntax and intuitive design patterns for rapid development

Cons of Laravel

  • Steeper learning curve for beginners compared to API-focused solutions
  • Potentially heavier resource usage due to its comprehensive feature set
  • May require more configuration for API-only projects

Code Comparison

Laravel (routes/api.php):

Route::middleware('auth:api')->get('/user', function (Request $request) {
    return $request->user();
});

Dingo (app/Http/routes.php):

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', function ($api) {
    $api->get('user', 'App\Http\Controllers\UserController@index');
});

Laravel provides a more straightforward routing syntax, while Dingo offers version-specific API routing out of the box. Laravel's approach is simpler for general web applications, but Dingo's method is tailored for API development with built-in versioning support.

Both frameworks offer powerful features for building web applications and APIs, with Laravel providing a more comprehensive solution and Dingo focusing specifically on API development. The choice between them depends on project requirements and developer preferences.

29,705

The Symfony PHP framework

Pros of Symfony

  • More comprehensive framework with a wider range of features and components
  • Larger community and ecosystem, providing better support and resources
  • Well-established and battle-tested in enterprise-level applications

Cons of Symfony

  • Steeper learning curve due to its extensive feature set
  • Can be overkill for smaller projects or simple APIs
  • Potentially slower performance compared to lightweight alternatives

Code Comparison

Symfony route definition:

/**
 * @Route("/api/users", name="get_users", methods={"GET"})
 */
public function getUsers(): JsonResponse
{
    // ...
}

Dingo API route definition:

$api->get('users', 'App\Http\Controllers\UserController@index');

Symfony offers a more annotation-based approach for defining routes, while Dingo API uses a more concise, fluent syntax. Symfony's method provides more metadata and is more self-documenting, but Dingo's approach is simpler and quicker to write.

Both frameworks have their strengths, with Symfony being more suitable for large-scale applications and Dingo API excelling in rapid API development. The choice between them depends on project requirements, team expertise, and scalability needs.

8,678

CakePHP: The Rapid Development Framework for PHP - Official Repository

Pros of CakePHP

  • Full-featured MVC framework with built-in ORM, authentication, and caching
  • Extensive documentation and large community support
  • Follows convention over configuration, leading to faster development

Cons of CakePHP

  • Steeper learning curve for beginners compared to API-focused solutions
  • Can be overkill for simple API projects
  • Performance may be slower due to its full-stack nature

Code Comparison

CakePHP (Controller):

class ArticlesController extends AppController
{
    public function index()
    {
        $articles = $this->Articles->find('all');
        $this->set(compact('articles'));
    }
}

Dingo API (Controller):

class ArticleController extends Controller
{
    public function index()
    {
        return $this->response->collection(Article::all(), new ArticleTransformer);
    }
}

Summary

CakePHP is a comprehensive PHP framework suitable for full-stack web applications, while Dingo API is specifically designed for building and consuming APIs. CakePHP offers more built-in features and follows a structured approach, which can be beneficial for larger projects. However, Dingo API provides a more focused and lightweight solution for API development, with features like API versioning and rate limiting out of the box. The choice between the two depends on the project requirements and the developer's familiarity with each framework.

14,235

Yii 2: The Fast, Secure and Professional PHP Framework

Pros of Yii2

  • Full-featured PHP framework with built-in tools for rapid web development
  • Strong community support and extensive documentation
  • Integrated database abstraction layer and ActiveRecord ORM

Cons of Yii2

  • Steeper learning curve for beginners compared to API-focused solutions
  • Heavier footprint and potentially slower performance for simple API projects
  • Less flexibility for custom API architectures

Code Comparison

Yii2 (Controller action):

public function actionIndex()
{
    $models = User::find()->all();
    return $this->asJson($models);
}

Dingo API (Controller action):

public function index()
{
    $users = User::all();
    return $this->response->collection($users, new UserTransformer);
}

Summary

Yii2 is a comprehensive PHP framework suitable for full-stack web applications, while Dingo API is specifically designed for building and consuming APIs. Yii2 offers more built-in features and tools but may be overkill for simple API projects. Dingo API provides a more focused and lightweight solution for API development with features like API versioning and rate limiting out of the box. The choice between the two depends on the project requirements and the developer's familiarity with each framework.

11,964

Slim is a PHP micro framework that helps you quickly write simple yet powerful web applications and APIs.

Pros of Slim

  • Lightweight and minimalistic framework, ideal for small to medium-sized projects
  • Easy to learn and use, with a gentle learning curve
  • Highly flexible and customizable, allowing developers to add only the features they need

Cons of Slim

  • Less built-in functionality compared to more comprehensive frameworks
  • May require additional third-party libraries for complex applications
  • Limited out-of-the-box support for API-specific features

Code Comparison

Slim route definition:

$app->get('/hello/{name}', function (Request $request, Response $response, array $args) {
    $name = $args['name'];
    $response->getBody()->write("Hello, $name");
    return $response;
});

Dingo API route definition:

$api->get('hello/{name}', function ($name) {
    return "Hello, $name";
});

Both frameworks offer simple and intuitive route definitions, but Dingo API provides a more concise syntax specifically tailored for API development. Slim's approach is more verbose but offers greater flexibility in handling requests and responses directly.

While Slim is a general-purpose micro-framework, Dingo API is specifically designed for building APIs, offering features like API versioning, rate limiting, and authentication out of the box. Slim may require additional setup and configuration to achieve similar functionality, but it provides more freedom in structuring your application.

64,773

Fast, unopinionated, minimalist web framework for node.

Pros of Express

  • Larger community and ecosystem, with more middleware and plugins available
  • More flexible and unopinionated, allowing for greater customization
  • Faster performance due to its lightweight nature

Cons of Express

  • Requires more boilerplate code for common tasks
  • Less structured approach can lead to inconsistent code organization
  • Lacks built-in support for some modern features like async/await

Code Comparison

Express:

const express = require('express');
const app = express();

app.get('/', (req, res) => {
  res.send('Hello World!');
});

Dingo:

$api = app('Dingo\Api\Routing\Router');

$api->version('v1', function ($api) {
    $api->get('/', function () {
        return 'Hello World!';
    });
});

Both examples show a basic route setup for a "Hello World" response. Express uses a more straightforward approach, while Dingo requires a bit more setup but provides versioning out of the box.

Express is a minimal and flexible Node.js web application framework, offering a robust set of features for web and mobile applications. Dingo is a RESTful API package for the Laravel PHP framework, providing a set of tools to quickly build and manage APIs.

While Express gives developers more freedom in structuring their applications, Dingo offers a more opinionated approach with built-in features tailored for API development in the Laravel ecosystem.

Convert Figma logo designs to code with AI

Visual Copilot

Introducing Visual Copilot: A new AI model to turn Figma designs to high quality code using your components.

Try Visual Copilot

README

Move repositories notice

Unfortunately this package cannot be maintained at this location anymore due to broken CI integrations, and travis-ci likely can't be used much longer either due to their change to paid plans. This project is still being actively maintained, we ask you to please switch to the following repository: https://github.com/api-ecosystem-for-laravel/dingo-api


The Dingo API package is meant to provide you, the developer, with a set of tools to help you easily and quickly build your own API. While the goal of this package is to remain as flexible as possible it still won't cover all situations and solve all problems.

Build Status License Development Version Monthly Installs StyleCI

Features

This package provides tools for the following, and more:

  • Content Negotiation
  • Multiple Authentication Adapters
  • API Versioning
  • Rate Limiting
  • Response Transformers and Formatters
  • Error and Exception Handling
  • Internal Requests
  • API Blueprint Documentation

Documentation

Please refer to our extensive Wiki documentation for more information.

API Boilerplate

If you are looking to start a new project from scratch, consider using the Laravel API Boilerplate, which builds on top of the dingo-api package, and adds a lot of great features.

Support

For answers you may not find in the Wiki, avoid posting issues. Feel free to ask for support on the dedicated Slack room. Make sure to mention specialtactics so he is notified.

License

This package is licensed under the BSD 3-Clause license.