PHPackages                             delejt/y2apidoc - 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. delejt/y2apidoc

ActiveLibrary

delejt/y2apidoc
===============

Yet Another Api Docs Generator

1.1.0(7y ago)09MITPHPPHP &gt;=7.1.0

Since Dec 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/delejt/y2apidoc)[ Packagist](https://packagist.org/packages/delejt/y2apidoc)[ RSS](/packages/delejt-y2apidoc/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)DependenciesVersions (11)Used By (0)

Yet Another ApiDoc Generator for Laravel
========================================

[](#yet-another-apidoc-generator-for-laravel)

Automatically generate your API documentation from existing Laravel routing and Class/methods docblocks

```
php artisan y2apidoc:generate

```

Some screenshots
----------------

[](#some-screenshots)

- [y2apidoc](doc/1st.png)
- [y2apidoc - method](doc/method.png)

Prerequisites
-------------

[](#prerequisites)

- PHP 7
- Laravel 5.6

Installing
----------

[](#installing)

```
$ composer require delejt/y2apidoc

```

Publishing config and template files
------------------------------------

[](#publishing-config-and-template-files)

```
php artisan vendor:publish --provider="Delejt\Y2apidoc\ServiceProvider" --tag="config"

```

```
php artisan vendor:publish --provider="Delejt\Y2apidoc\ServiceProvider" --tag="template"

```

Configuration
-------------

[](#configuration)

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

- configure your api routing prefix:

```
 'route' => [
     'prefix' => 'api',
 ],

```

- change your documentation output path

```
'documentation' => [
    'output' => 'public/api-documentation',
 ...

```

- you can change template for documentation (default is bootstrap 3.3 simple template)

```
'source' => 'resources/views/vendor/y2apidoc/default',

```

- path for custom tags special templates, name of the file must be \[tag\_name\]tag.blade.php, ex.: tabletag.blade.php

```
'tags_template_path' => 'resources/views/vendor/y2apidoc/default/_partials/tags',

```

- specify custom languages templates (PHP/Shell included):

```
'languages' => 'resources/views/vendor/y2apidoc/default/_partials/langs',

```

- specify available tags for parser (or add your own), You can place here custom renderer class

```
'tags' => [
    "@table" => [
        'class' => '\\Delejt\\Y2apidoc\\Tags\\TableTag',
    ],
     "@notice" => [
         'class' => '\\Delejt\\Y2apidoc\\Tags\\NoticeTag',
     ],
     "@warning" => [
         'class' => '\\Delejt\\Y2apidoc\\Tags\\WarningTag',
     ],
     //"@api" => [],
     "@author" => [],

...

```

- specify default headers added to all request:

```
 'request' => [
     'headers' => [
         'Accept' => 'application/json',
         'Content-Type' => 'application/x-www-form-urlencoded',
         'Authorization' => 'Bearer: {token}',
     ],

```

- specify bindings - variables will automatically replaced during documentation generation process:

```
'bindings' => [
     '{token}' => 'qwerty',
     '{page}' => '1',
     '{item_per_page}' => '30',
     '{page?}' => '1',
     ...

```

- specify bootstrap classes using for labelling method as PUT/POST/PATCH/DELETE/GET

```
 'classes' => [
     'get' => 'success',
     'post' => 'primary',
     'put' => 'warning',
     'delete' => 'danger',
 ],

```

- configure headers automatically added to each response:

```
 'response' => [
     'headers' => [
         'Content-Type' => 'application/json',
         'Accept' => 'application/json',
     ],
 ],

```

Documentation
-------------

[](#documentation)

Y2apidoc uses HTTP controller doc blocks to create a table of contents and show descriptions for your API methods. Package automatically create groups from controller names. All routes handled by that controller will placed under this group in the [sidebar menu](doc/aside.png)

Tags
----

[](#tags)

This package uses standard php [DocBlock comments](http://docs.phpdoc.org/guides/docblocks.html). Packages has custom Tags defined too.

- @notice sample notice message presented as bootstrap alert, example:

    ```
    @notice Simple Notice.

    ```
- @warning sample warning message presented as bootstrap alert

    ```
    @warning Simple Warning.

    ```
- @table tag to create table in your documentation - example for special params list

    ```
     @table Type|Name|Requirements|Description
     int|page|required|Page Number, example: 1
     int|item_per_page|required|Items per page, example: 32
     int|ean|optional|EAN13 if you specify this parameter

    ```
- @response tag to show example response from current method

    ```
    @response {
        "success": true,
        "data": {
          "id": 55597,
          "product_id": 59863,
          "warehouse_id": 1,
          "quantity": 1333,
          "delivery_time": 48,
          "created_at": "2018-09-25 10:43:25",
          "updated_at": "2018-12-07 12:29:09"
        },
        "message": "Record updated successfully."
      }

    ```
- @responsefile tag to show response from current method - see Response File section

    ```
    @responsefile product.index.json

    ```

Custom Tags...
==============

[](#custom-tags)

You can define custom tags by adding it's name to config file, example:

```
'tags' => [
    "@mikimouse",
...

```

You can specify custom renderer for this tag by putting class path:

```
 "@mikimouse" => [
     'class' => '\\Some\\Custom\\Namespace\\MikiMouseTag',
 ],

```

Next create class with 'parse' method in given path:

```
