PHPackages                             nickkuijpers/laravel-apidoc-generator - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. nickkuijpers/laravel-apidoc-generator

ActiveLibrary[API Development](/categories/api)

nickkuijpers/laravel-apidoc-generator
=====================================

Generate beautiful API documentation from your Laravel application

3.5.2(6y ago)039MITPHPPHP &gt;=7.0.0

Since May 3Pushed 6y ago1 watchersCompare

[ Source](https://github.com/nickkuijpers/laravel-apidoc-generator)[ Packagist](https://packagist.org/packages/nickkuijpers/laravel-apidoc-generator)[ Docs](http://github.com/mpociot/laravel-apidoc-generator)[ RSS](/packages/nickkuijpers-laravel-apidoc-generator/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)Dependencies (12)Versions (65)Used By (0)

Laravel API Documentation Generator
-----------------------------------

[](#laravel-api-documentation-generator)

Automatically generate your API documentation from your existing Laravel/Lumen/[Dingo](https://github.com/dingo/api) routes. [Here's what the output looks like](http://marcelpociot.de/whiteboard/).

`php artisan apidoc:generate`

[![Latest Stable Version](https://camo.githubusercontent.com/bba71f22d782775019edd5f4bed7539a218433ba1b240f106df7192881a1b44a/68747470733a2f2f706f7365722e707567782e6f72672f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722f762f737461626c65)](https://packagist.org/packages/mpociot/laravel-apidoc-generator)[![Total Downloads](https://camo.githubusercontent.com/99c78134bd21ded802f02a27a608d5d56a3ed84d58f8ff3e13766674fd0459fb/68747470733a2f2f706f7365722e707567782e6f72672f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722f646f776e6c6f616473)](https://packagist.org/packages/mpociot/laravel-apidoc-generator)[![License](https://camo.githubusercontent.com/5c9f3944c2c3569fac0103d035f95f317981dfa63d61b4caa1d90e88a0a50137/68747470733a2f2f706f7365722e707567782e6f72672f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722f6c6963656e7365)](https://packagist.org/packages/mpociot/laravel-apidoc-generator)[![codecov.io](https://camo.githubusercontent.com/c98e2711203f0b61a8a4306e07fd49e080dbf9a3e203f3516151106a5ae74cd7/68747470733a2f2f636f6465636f762e696f2f6769746875622f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722f636f7665726167652e7376673f6272616e63683d6d6173746572)](https://codecov.io/github/mpociot/laravel-apidoc-generator?branch=master)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/36a7cf72482e6fb664d147972ee9cf8ef1f96a54b0136fc7b113240696b79c97/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/mpociot/laravel-apidoc-generator/?branch=master)[![Build Status](https://camo.githubusercontent.com/0ffc08efeb5478bcde22dce1dcc2342fc97b1fc433590ae7d86e8c450468efc3/68747470733a2f2f7472617669732d63692e6f72672f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/mpociot/laravel-apidoc-generator)[![StyleCI](https://camo.githubusercontent.com/bc0002baa65e566617a950bdab9499c5698fe4cfbd49bd1affd8cd830a651533/68747470733a2f2f7374796c6563692e696f2f7265706f732f35373939393239352f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/57999295)

> Note: this is the documentation for version 3, which changes significantly from version 2. if you're on v2, you can check out its documentation [here](https://github.com/mpociot/laravel-apidoc-generator/blob/2.x/README.md). We strongly recommend you upgrade, though, as v3 is more robust and fixes a lot of the problems with v2.

Installation
------------

[](#installation)

> Note: PHP 7 and Laravel 5.5 or higher are required.

```
$ composer require nickkuijpers/laravel-apidoc-generator
```

### Laravel

[](#laravel)

Publish the config file by running:

```
php artisan vendor:publish --provider="Mpociot\ApiDoc\ApiDocGeneratorServiceProvider" --tag=apidoc-config
```

This will create an `apidoc.php` file in your `config` folder.

### Lumen

[](#lumen)

- Register the service provider in your `bootstrap/app.php`:

```
$app->register(\Mpociot\ApiDoc\ApiDocGeneratorServiceProvider::class);
```

- Copy the config file from `vendor/mpociot/laravel-apidoc-generator/config/apidoc.php` to your project as `config/apidoc.php`. Then add to your `bootstrap/app.php`:

```
$app->configure('apidoc');
```

Usage
-----

[](#usage)

Before you can generate your documentation, you'll need to configure a few things in your `config/apidoc.php`.

- `output`This is the file path where the generated documentation will be written to. Default: **public/docs**
- `postman`This package can automatically generate a Postman collection for your routes, along with the documentation. This section is where you can configure (or disable) that.
- `router`The router to use when processing the route (can be Laravel or Dingo. Defaults to **Laravel**)
- `logo`You can specify your custom logo to be used on the generated documentation. Set the `logo` option to an absolute path pointing to your logo file.
- `routes`This is where you specify what rules documentation should be generated for. You specify routes to be parsed by defining conditions that the routes should meet and rules that should be applied when generating documentation. These conditions and rules are specified in groups, allowing you to apply different rules to different routes.

For instance, suppose your configuration looks like this:

```
return [
     //...,

     'routes' => [
          [
              'match' => [
                  'domains' => ['*'],
                  'prefixes' => ['api/*', 'v2-api/*'],
                  'versions' => ['v1'],
              ],
              'include' => ['users.index', 'healthcheck*'],
              'exclude' => ['users.create', 'admin.*'],
              'apply' => [
                  'headers' => [
                      'Authorization' => 'Bearer: {token}',
                  ],
              ],
          ],
];
```

This means documentation will be generated for routes in all domains ('\*' is a wildcard meaning 'any character') which match any of the patterns 'api/\*' or 'v2-api/\*', excluding the 'users.create' route and any routes whose names begin with `admin.`, and including the 'users.index' route and any routes whose names begin with `healthcheck.`. (The `versions` key is ignored unless you are using Dingo router). Also, in the generated documentation, these routes will have the header 'Authorization: Bearer: {token}' added to the example requests.

You can also separate routes into groups to apply different rules to them:

```
