PHPackages                             blasttech/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. blasttech/laravel-apidoc-generator

ActiveLibrary[API Development](/categories/api)

blasttech/laravel-apidoc-generator
==================================

Generate beautiful API documentation from your Laravel application

1.7.5(7y ago)07.4k1MITPHPPHP &gt;=5.5.0

Since May 3Pushed 7y ago5 watchersCompare

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

READMEChangelog (2)Dependencies (9)Versions (52)Used By (0)

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

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

Automatically generate your API documentation from your existing Laravel routes. A fork of the original [laravel-apidoc-generator](https://github.com/mpociot/laravel-apidoc-generator/) by Marcel Pociot. Take a look at his [example documentation](http://marcelpociot.com/whiteboard/).

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

[![image](https://camo.githubusercontent.com/db9439bb3e7d07fdc0d6aede352c965e3ed62f161e3806db3dcf41adba2050bd/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/db9439bb3e7d07fdc0d6aede352c965e3ed62f161e3806db3dcf41adba2050bd/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722e7376673f7374796c653d666c6174)[![image](https://camo.githubusercontent.com/f290f302133c913e22d7c3dd2a59fb0641290deccacee016cca09c95a97a1c63/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722e7376673f7374796c653d666c6174)](https://camo.githubusercontent.com/f290f302133c913e22d7c3dd2a59fb0641290deccacee016cca09c95a97a1c63/687474703a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d706f63696f742f6c61726176656c2d617069646f632d67656e657261746f722e7376673f7374796c653d666c6174)[![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/6835b8787cae47bd28dc11b95988bdfba772c57f6bb0dcdf61d8d76043461873/68747470733a2f2f7374796c6563692e696f2f7265706f732f35373939393239352f736869656c64)](https://styleci.io/repos/57999295)[![Dependency Status](https://camo.githubusercontent.com/20c3f061c8cae5c30500f30625d968b67d80e2bc0ddd11f8ba7c254839b13f41/68747470733a2f2f7777772e76657273696f6e6579652e636f6d2f7068702f6d706f63696f743a6c61726176656c2d617069646f632d67656e657261746f722f6465762d6d61737465722f62616467653f7374796c653d666c6174)](https://www.versioneye.com/php/mpociot:laravel-apidoc-generator/dev-master)

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

[](#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:

```
Blasttech\ApiDoc\ApiDocGeneratorServiceProvider::class,
```

This package uses two extra validation rules in Laravel. If you wish to use these, you need to add the following to your AppServiceProvider.php

```
public function boot()
{
    Validator::extend('description', function ($field, $value, $parameters) {
        return true;
    });
    Validator::extend('faker', function ($field, $value, $parameters) {
        return true;
    });
}
```

> Using Laravel &lt; 5.4? Use version 1.0! For Laravel 5.4 and up, use 2.0 instead.

Usage
-----

[](#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. For example:

```
// API Group Routes
Route::group(array('prefix' => 'api/v1', 'middleware' => []), function () {
	// Custom route added to standard Resource
	Route::get('example/foo', 'ExampleController@foo');
	// Standard Resource route
	Route::resource('example', 'ExampleController'));
});
```

### Available command options:

[](#available-command-options)

OptionDescription`output` The output path used for the generated documentation. Default: `public/docs``routePrefix`The route prefix to use for generation - `*` can be used as a wildcard`routes`The route names to use for generation - Required if no routePrefix is provided`middleware`The middlewares to use for generation`noResponseCalls`Disable API response calls`noPostmanCollection`Disable Postman collection creation`useMiddlewares`Use all configured route middlewares (Needed for Laravel 5.3 `SubstituteBindings` middleware)`actAsUserId`The user ID to use for authenticated API response calls`router`The router to use, when processing the route files (can be Laravel or Dingo - defaults to Laravel)`bindings`List of route bindings that should be replaced when trying to retrieve route results. Syntax format: `binding\_one,id`force`Force the re-generation of existing/modified API routes`header`Custom HTTP headers to add to the example requests. Separate the header name and value with ":". For example: `--header 'Authorization: CustomToken'``locale`The locale to use for Faker results. Default: `en_us``methods`The HTTP methods which are allowed to be displayed - defaults to all. For example, `--methods=GET,POST``tags`Include API URL tags descriptions from phpdocsPublish rule descriptions for customisation or translation.
-----------------------------------------------------------

[](#publish-rule-descriptions-for-customisation-or-translation)

By default, this package returns the descriptions in english. You can publish the packages language files, to customise and translate the documentation output.

```
$ php artisan vendor:publish
```

After the files are published you can customise or translate the descriptions in the language you want by renaming the `en` folder and editing the files in `public/vendor/apidoc/resources/lang`.

### How does it work?

[](#how-does-it-work)

This package uses these resources to generate the API documentation:

#### Controller doc block

[](#controller-doc-block)

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

Using `@resource` in a doc block prior to each controller is useful as it creates a Group within the API documentation for all methods defined in that controller (rather than listing every method in a single list for all your controllers), but using `@resource` is not required. The short description after the `@resource` should be unique to allow anchor tags to navigate to this section. A longer description can be included below.

Above each method within the controller you wish to include in your API documentation you should have a doc block. This should include a unique short description as the first entry. An optional second entry can be added with further information. Both descriptions will appear in the API documentation in a different format as shown below.

```
/**
 * @resource Example
 *
 * Longer description
 */
class ExampleController extends Controller {

	/**
	 * This is the short description [and should be unique as anchor tags link to this in navigation menu]
	 *
	 * This can be an optional longer description of your API call, used within the documentation.
	 *
	 */
	 public function foo(){

	 }
```

**Result:**

[![Doc block result](https://camo.githubusercontent.com/5acbb8764bb5b4b40504968cf5618fc0e2f71f006d4cb712bb0773c219d7bd16/687474703a2f2f6865616473717561726564736f6674776172652e636f2e756b2f696d616765732f6170695f67656e657261746f725f646f63626c6f636b2e706e67)](https://camo.githubusercontent.com/5acbb8764bb5b4b40504968cf5618fc0e2f71f006d4cb712bb0773c219d7bd16/687474703a2f2f6865616473717561726564736f6674776172652e636f2e756b2f696d616765732f6170695f67656e657261746f725f646f63626c6f636b2e706e67)

#### Form request validation rules

[](#form-request-validation-rules)

To display a list of valid parameters, your API methods accepts, this package uses Laravels [Form Requests Validation](https://laravel.com/docs/5.2/validation#form-request-validation).

```
public function rules()
{
    return [
        'title' => 'required|max:255',
        'body' => 'required',
        'type' => 'in:foo,bar',
        'thumbnail' => 'required_if:type,foo|image',
    ];
}
```

**Result:** [![Form Request](https://camo.githubusercontent.com/bbfde84c1a88d740a02896f51757e519f987fade9af9cdf633c92aff28f522c6/687474703a2f2f6d617263656c706f63696f742e64652f646f63756d656e74617269616e2f666f726d5f726571756573742e706e67)](https://camo.githubusercontent.com/bbfde84c1a88d740a02896f51757e519f987fade9af9cdf633c92aff28f522c6/687474703a2f2f6d617263656c706f63696f742e64652f646f63756d656e74617269616e2f666f726d5f726571756573742e706e67)

As well as the standard rules above, descriptions can be extended in the Description column by adding a description rule, like below:

```
public function rules()
{
    return [
        'title' => 'required|max:255|description:The book\'s title.',
        'body' => 'required|description:Should be a full description of the book.',
    ];
}
```

Also, you can set a rule to force a certain faker type to be used in the example requests which are generated. For example:

```
public function rules()
{
    return [
        'phone_number' => 'description:The user\'s phone number|faker:phoneNumber',
        'password' => 'required|description:The user\'s password|faker:password',
    ];
}
```

> Note: If you use the description or faker rules, make sure you modify your AppServiceProvider.php as shown above.

#### API responses

[](#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.

If your API needs an authenticated user, you can use the `actAsUserId` option to specify a user ID that will be used for making these API calls:

```
$ php artisan api:generate --routePrefix="api/*" --actAsUserId=1
```

If you don't want to automatically perform API response calls, use the `noResponseCalls` option.

```
$ php artisan api:generate --routePrefix="api/*" --noResponseCalls
```

> Note: The example API responses work best with seeded data.

#### Postman collections

[](#postman-collections)

The generator automatically creates a Postman collection file, which you can import to use within your [Postman App](https://www.getpostman.com/apps) for even simpler API testing and usage.

If you don't want to create a Postman collection, use the `--noPostmanCollection` option, when generating the API documentation.

As of as of Laravel 5.3, the default base URL added to the Postman collection will be that found in your Laravel `config/app.php` file. This will likely be `http://localhost`. If you wish to change this setting you can directly update the url or link this config value to your environment file to make it more flexible (as shown below):

```
'url' => env('APP_URL', 'http://yourappdefault.app'),
```

If you are referring to the environment setting as shown above, then you should ensure that you have updated your `.env` file to set the APP\_URL value as appropriate. Otherwise the default value (`http://yourappdefault.app`) will be used in your Postman collection. Example environment value:

```
APP_URL=http://yourapp.app

```

Modify the generated documentation
----------------------------------

[](#modify-the-generated-documentation)

If you want to modify the content of your generated documentation, go ahead and edit the generated `index.md` file. The default location of this file is: `public/docs/source/index.md`.

After editing the markdown file, use the `api:update` command to rebuild your documentation as a static HTML file.

```
$ php artisan api:update
```

As an optional parameter, you can use `--location` to tell the update command where your documentation can be found.

Skip single routes
------------------

[](#skip-single-routes)

If you want to skip a single route from a list of routes that match a given prefix, you can use the `@hideFromAPIDocumentation` tag on the Controller method you do not want to document.

Further modification
--------------------

[](#further-modification)

This package uses [Documentarian](https://github.com/mpociot/documentarian) to generate the API documentation. If you want to modify the CSS files of your documentation, or simply want to learn more about what is possible, take a look at the [Documentarian guide](http://marcelpociot.de/documentarian/installation).

### License

[](#license)

The Laravel API Documentation Generator is free software licensed under the MIT license.

###  Health Score

35

—

LowBetter than 79% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community22

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 68.4% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~22 days

Recently: every ~97 days

Total

49

Last Release

2612d ago

Major Versions

0.2.0 → 1.0.02016-05-11

PHP version history (2 changes)0.1.0PHP &gt;=7.0.0

1.1.1PHP &gt;=5.5.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/f99e8c76b2ec65ebcc2c9c346839736e22e9f5d503e23272319937bc60ffe211?d=identicon)[mhkb](/maintainers/mhkb)

---

Top Contributors

[![mpociot](https://avatars.githubusercontent.com/u/804684?v=4)](https://github.com/mpociot "mpociot (173 commits)")[![mhkb](https://avatars.githubusercontent.com/u/4683976?v=4)](https://github.com/mhkb "mhkb (25 commits)")[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (21 commits)")[![joaofelipemr](https://avatars.githubusercontent.com/u/19332729?v=4)](https://github.com/joaofelipemr "joaofelipemr (7 commits)")[![grinry](https://avatars.githubusercontent.com/u/5575688?v=4)](https://github.com/grinry "grinry (5 commits)")[![fergthh](https://avatars.githubusercontent.com/u/9524225?v=4)](https://github.com/fergthh "fergthh (4 commits)")[![ivanhennig](https://avatars.githubusercontent.com/u/6207878?v=4)](https://github.com/ivanhennig "ivanhennig (2 commits)")[![idirouhab](https://avatars.githubusercontent.com/u/1987319?v=4)](https://github.com/idirouhab "idirouhab (2 commits)")[![MarkVaughn](https://avatars.githubusercontent.com/u/39970?v=4)](https://github.com/MarkVaughn "MarkVaughn (2 commits)")[![travoltron](https://avatars.githubusercontent.com/u/2647090?v=4)](https://github.com/travoltron "travoltron (1 commits)")[![yespbs](https://avatars.githubusercontent.com/u/478293?v=4)](https://github.com/yespbs "yespbs (1 commits)")[![atorscho](https://avatars.githubusercontent.com/u/7644596?v=4)](https://github.com/atorscho "atorscho (1 commits)")[![zakhttp](https://avatars.githubusercontent.com/u/16402019?v=4)](https://github.com/zakhttp "zakhttp (1 commits)")[![f3cp](https://avatars.githubusercontent.com/u/2740293?v=4)](https://github.com/f3cp "f3cp (1 commits)")[![jcorrego](https://avatars.githubusercontent.com/u/2152949?v=4)](https://github.com/jcorrego "jcorrego (1 commits)")[![justcodingnobb](https://avatars.githubusercontent.com/u/16287171?v=4)](https://github.com/justcodingnobb "justcodingnobb (1 commits)")[![linkthrow](https://avatars.githubusercontent.com/u/16664738?v=4)](https://github.com/linkthrow "linkthrow (1 commits)")[![maikenunes](https://avatars.githubusercontent.com/u/4635672?v=4)](https://github.com/maikenunes "maikenunes (1 commits)")[![nerijunior](https://avatars.githubusercontent.com/u/17169?v=4)](https://github.com/nerijunior "nerijunior (1 commits)")[![rick-hidef](https://avatars.githubusercontent.com/u/3083488?v=4)](https://github.com/rick-hidef "rick-hidef (1 commits)")

---

Tags

apilaraveldocumentation

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/blasttech-laravel-apidoc-generator/health.svg)

```
[![Health](https://phpackages.com/badges/blasttech-laravel-apidoc-generator/health.svg)](https://phpackages.com/packages/blasttech-laravel-apidoc-generator)
```

###  Alternatives

[knuckleswtf/scribe

Generate API documentation for humans from your Laravel codebase.✍

2.3k12.2M45](/packages/knuckleswtf-scribe)[mpociot/laravel-apidoc-generator

Generate beautiful API documentation from your Laravel application

3.5k3.1M12](/packages/mpociot-laravel-apidoc-generator)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
