PHPackages                             johnylemon/laravel-apidocs - 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. johnylemon/laravel-apidocs

ActiveLibrary[API Development](/categories/api)

johnylemon/laravel-apidocs
==========================

Laravel API documentation generating tool

1.1.0(5y ago)472.8k4[1 PRs](https://github.com/johnylemon/laravel-apidocs/pulls)MITPHPPHP ^7.3 || ^8.0

Since Nov 10Pushed 5y ago2 watchersCompare

[ Source](https://github.com/johnylemon/laravel-apidocs)[ Packagist](https://packagist.org/packages/johnylemon/laravel-apidocs)[ RSS](/packages/johnylemon-laravel-apidocs/feed)WikiDiscussions main Synced 1mo ago

READMEChangelogDependencies (3)Versions (6)Used By (0)

Laravel API documentation generating tool
=========================================

[](#laravel-api-documentation-generating-tool)

[![GitHub Workflow Status](https://camo.githubusercontent.com/e1e14520079d6bf42264beed84fcdc715d4de9f39c1bdf540f4f7c501c696c64/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a6f686e796c656d6f6e2f6c61726176656c2d617069646f63732f74657374733f6c6162656c3d7465737473)](https://camo.githubusercontent.com/e1e14520079d6bf42264beed84fcdc715d4de9f39c1bdf540f4f7c501c696c64/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f6a6f686e796c656d6f6e2f6c61726176656c2d617069646f63732f74657374733f6c6162656c3d7465737473)[![GitHub tag (latest by date)](https://camo.githubusercontent.com/1b9936ca2cf8128203b5ec2cbaae26ff9de9bbe1891a480a6ef1ec99616a91cb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6a6f686e796c656d6f6e2f6c61726176656c2d617069646f6373)](https://camo.githubusercontent.com/1b9936ca2cf8128203b5ec2cbaae26ff9de9bbe1891a480a6ef1ec99616a91cb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f7461672f6a6f686e796c656d6f6e2f6c61726176656c2d617069646f6373)

### The problem

[](#the-problem)

I don't like writing tons of lines of stupid annotations just to have hope that api documentation will be generated correctly without errors that says nothing. And I am not the only one. [More](WHY.md).

This package solves this problem the way I like - by writing PHP code.

### The solution

[](#the-solution)

This package adds `apidocs` method to [Laravel](https://github.com/laravel/laravel) routes, where you can define route definitions using code you use every day.

**This way you can:**

- reuse, extend and modify existing api definitions
- create generic endpoint definitions and just modify them ad-hoc or by creating child classes
- define multiple examples
- define multiple sample responses
- define and reuse parameter definitions
- make your controllers readable again

[![img](screenshot.png)](screenshot.png)

Getting started
---------------

[](#getting-started)

1. Add `johnylemon/laravel-apidocs` repository

```
composer require johnylemon/laravel-apidocs

```

2. Register `Johnylemon\Apidocs\Providers\ApidocsServiceProvider` provider if not registered automagically .
3. Install package. This command will publish all required assets.

```
php artisan apidocs:install

```

4. **Enjoy!**

Generating route documentation
------------------------------

[](#generating-route-documentation)

This package ships with command for rapid route definition generation.

```
php artisan apidocs:endpoint SampleEndpoint

```

Brand new `SampleEndpoint` class will be placed within `app\Apidocs\Endpoints` directory. Target directory may be changed within your `apidocs` config file.

This class contains only one `describe` method, where you have to use any of available methods that will describe your endpoint. Like that:

```
