Laravel API Documentation Generator is a cool package that we can use to automatically generate our API Documentation.

Laravel APID Doc

Introduction

Automatically generate your API documentation from your existing Laravel routes.

Take a look at the example documentation.

php artisan api:gen --routePrefix=settings/api/*

Installation

Require this package with composer using the following command:

$ composer require mpociot/laravel-apidoc-generator

Go to your config/app.php and add the service provider:

Mpociot\ApiDoc\ApiDocGeneratorServiceProvider::class

Usage

To generate your API documentation, use the api:generate artisan command.

$ php artisan api:generate --routePrefix=api/v1/*

This command will scan your applications routes for the URIs matching api/v1/* and will parse these controller methods and form requests.

How does it work?

This package uses these resources to generated the API documentation:

Controller doc block

This package uses the HTTP controller doc blocks to create a table of contents and show descriptions for your API methods.

/**
 * This is the short description
 *
 * This can be an optional longer description of your API call, used within the documentation.
 *
 */
 public function foo()

Result:

![diagram][3]

API responses

If your API route accepts a GET method, this package tries to call the API route with all middleware disabled to fetch an example API response.