2017 © Pedro Peláez
 

library laravel-apidocs

API Documentation generator for Laravel

image

mhamlet/laravel-apidocs

API Documentation generator for Laravel

  • Sunday, May 21, 2017
  • by mhamlet
  • Repository
  • 1 Watchers
  • 6 Stars
  • 5 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 2 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

Laravel API Documentation generator

Latest Version Build Status Quality Score Total Downloads, (*1)

This Laravel package provides an API Documentation generator. It's based on your Routes and Controller Method DocBlock comments., (*2)

The package requires PHP >= 7.0 and Laravel 5.4., (*3)

Installation

Add the package in your composer.json by executing the command., (*4)

composer require mhamlet/laravel-apidocs

Next, add the service provider to config/app.php, (*5)

MHamlet\Apidocs\ApidocsServiceProvider::class,

Documentation

// The main class of package is MHamlet\Apidocs\Generator
// Let's write a simple "use"
use MHamlet\Apidocs\Generator;

// Generator has two statically declared methods - "forAllRoutes" and "forRoutesWithPrefix".

// The first one will provide you to generate documentation for all defined
// routes in your application.
$routeGenerator = Generator::forAllRoutes();

// The second one will provide you to generate documentation for routes,
// which URL's starts with given prefix.
$routeGenerator = Generator::forRoutesWithPrefix('api');

// The route generator also has two methods - "describeRoutes" and "generate"

// The first one will parse and describe the routes for you.
$routeGenerator->describeRoutes()

// It will return the following (the result is serialized in json to make it readable in this example)
/*
[
    {
        "path":"api/users",
        "controller":"App\\Http\\Controllers\\UserController",
        "method":"index",
        "verbs":[
            "GET",
            "HEAD"
        ]
    }
]
*/

// The second one will parse routes, controller comments and return the
// API documentation itself.
$routeGenerator->generate()

// It will return the following result
/*
[
    {
        "path":"api\/users",
        "verbs":[
            "GET",
            "HEAD"
        ],
        "description":"Returns list of all users",
        "params":[
            {
                "type":"int",
                "name":"from",
                "description":"test from"
            },
            {
                "type":"int",
                "name":"offset",
                "description":"test offset"
            }
        ],
    }
]
*/

License

This package is open-sourced software licensed under the MIT license, (*6)

The Versions

21/05 2017

dev-master

9999999-dev https://github.com/mhamlet/laravel-apidocs

API Documentation generator for Laravel

  Sources   Download

MIT

The Requires

 

The Development Requires

laravel api documentation generate mhamlet laravel-apidocs apidocs