PHPackages                             ovac/idoc - 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. ovac/idoc

ActiveLibrary[API Development](/categories/api)

ovac/idoc
=========

Generate beautiful API documentation from your Laravel application

v2.1.2(6mo ago)184477.6k↓27%431MITPHPPHP &gt;=7.0.0

Since Mar 31Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/ovac/idoc)[ Packagist](https://packagist.org/packages/ovac/idoc)[ Docs](http://github.com/ovac/idoc)[ RSS](/packages/ovac-idoc/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (11)Versions (20)Used By (1)

 [![](https://camo.githubusercontent.com/a7125b35dc591ca48c1b6ca3aa49ff2db2d3dfc522c82703779a029003007aba/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6f7661632f696d6167652f75706c6f61642f685f35302f76313535333937363438362f315f5166393478467764653432314a5f5a536d64504a44775f736f6565336d2e706e67)](https://www.openapis.org/)
[![](https://camo.githubusercontent.com/4df8eac0191a53df2390c529625401d251ebdcb751f329b4b2515ed051da5ddb/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6f7661632f696d6167652f75706c6f61642f685f35302f76313535333937353333302f4332493245464e325f343030783430305f716375796f702e6a7067)](https://www.openapis.org/)[![](https://camo.githubusercontent.com/da33047295fb89dc08896c2adb79be8cc4f659185a0e8f6e2733c3fbe56b35e2/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6f7661632f696d6167652f75706c6f61642f685f3132302f76313530363832383738362f6c6f676f2d636f6d706f7365722d7472616e73706172656e745f7a6a67616c302e706e67)](#)[![](https://camo.githubusercontent.com/bd19274b6f5c17fccda6394e6e3c96831ad26a49745be2b3ee47ff7fe914de71/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6f7661632f696d6167652f75706c6f61642f685f35302c775f36302c635f66696c6c2f76313530363833323939322f6c61726176656c2d6c6f676f5f61746c7666772e706e67)](#)
 [![](https://camo.githubusercontent.com/f0f644ff9bbb59eae4181c770db86ef64a4a3c3f8c0aebb35d284c02daec5248/68747470733a2f2f7265732e636c6f7564696e6172792e636f6d2f6f7661632f696d6167652f75706c6f61642f725f3230302c775f3330302c685f35302c635f66696c6c2f76313530363832383338302f6c6f676f5f73697a655f696e766572745f6a656c6837342e6a7067)](https://www.ovac4u.com/idoc)

[![Latest Stable Version](https://camo.githubusercontent.com/b66226175fcc95502740b94e7e9b7734ccebc5ca8cd6b73c623f2bffc06df41e/68747470733a2f2f706f7365722e707567782e6f72672f6f7661632f69646f632f762f737461626c65)](https://packagist.org/packages/ovac/idoc)[![Total Downloads](https://camo.githubusercontent.com/0c8498b726f0c5fc2cab92adc2845b9c8502b8974df18781af8fb24d975fd484/68747470733a2f2f706f7365722e707567782e6f72672f6f7661632f69646f632f646f776e6c6f616473)](https://packagist.org/packages/ovac/idoc)[![License](https://camo.githubusercontent.com/f433d3ed6643d3a7814fc4a149c7493046337a9b75c3216ec104c66a25c46098/68747470733a2f2f706f7365722e707567782e6f72672f6f7661632f69646f632f6c6963656e7365)](https://packagist.org/packages/ovac/idoc)

```
              Follow me anywhere @ovac4u                         | GitHub
              _________                          _________       | Twitter
             |   ___   |.-----.--.--.---.-.----.|  |  |.--.--.   | Facebook
             |  |  _   ||  _  |  |  |  _  |  __||__    |  |  |   | Instagram
             |  |______||_____|\___/|___._|____|   |__||_____|   | GitHub + @ovac
             |_________|                        www.ovac4u.com   | Facebook + @ovacposts
```

Laravel IDoc - The API Documentation Generator
----------------------------------------------

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

Automatically generate an interactive API documentation from your existing Laravel routes. Take a look at the [example documentation](https://redocly.github.io/redoc/). Inspired by [Laravel Api Documentation Generator](https://github.com/mpociot/laravel-apidoc-generator)

Introduction.
=============

[](#introduction)

Laravel IDoc generator (interactive documentation generator) is a seamless and complete plugin for generating API documentation from your Laravel's codebase. It is inspired by the laravel-apidoc-generator, ReDoc and the Open API initiative from Swagger. IDoc has been built with extendability so that it can easily adapt with your use case.

[![Demo](https://raw.githubusercontent.com/Rebilly/ReDoc/master/demo/redoc-demo.png)](https://raw.githubusercontent.com/Rebilly/ReDoc/master/demo/redoc-demo.png)

Features
--------

[](#features)

- Extremely easy deployment
- Server Side Rendering ready
- The widest OpenAPI v2.0 features support
    [![](https://raw.githubusercontent.com/Rebilly/ReDoc/master/docs/images/discriminator-demo.gif)](https://raw.githubusercontent.com/Rebilly/ReDoc/master/docs/images/discriminator-demo.gif){.inline}
- OpenAPI 3.0 support
- Neat **interactive** documentation for nested objects
    [![](https://raw.githubusercontent.com/Rebilly/ReDoc/master/docs/images/nested-demo.gif)](https://raw.githubusercontent.com/Rebilly/ReDoc/master/docs/images/nested-demo.gif){.inline}
- Automatic code sample support
    [![](https://raw.githubusercontent.com/Rebilly/ReDoc/master/docs/images/code-samples-demo.gif)](https://raw.githubusercontent.com/Rebilly/ReDoc/master/docs/images/code-samples-demo.gif){.inline}
- Responsive three-panel design with menu/scrolling synchronization
- Integrate API Introduction into side menu.
- High-level grouping in side-menu.
- Branding/customizations.
- Redoc OSS for fast, beautiful reading
- Optional Swagger UI side panel for live "Try it" requests
- Tag or operation aware, stays in sync while you navigate

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

[](#installation)

> Note: PHP 7 and Laravel 5.5 or higher are the minimum dependencies.

```
$ composer require ovac/idoc
```

### Laravel

[](#laravel)

Publish the config file by running:

```
php artisan vendor:publish --tag=idoc-config
```

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

### Lumen

[](#lumen)

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

```
$app->bind('path.public', function ($app) { return $app->basePath('../your-public-path'); });
$app->register(\OVAC\IDoc\IDocLumenServiceProvider::class);
```

- Copy the config file from `vendor/ovac/idoc/config/idoc.php` to your project as `config/idoc.php`. Then add to your `bootstrap/app.php`:

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

Usage
-----

[](#usage)

```
$ php artisan idoc:generate
```

### Theme

[](#theme)

- The docs page includes a single Theme toggle (Auto → Dark → Light) that applies to both Redoc and the Swagger UI Try-It panel.
- Auto follows your OS theme and updates live when the OS theme changes.
- The choice persists in your browser via localStorage; no backend configuration is required.

AI Chat (optional)
------------------

[](#ai-chat-optional)

The docs page ships with an optional, provider-agnostic AI assistant (ChatGPT‑style) that answers questions about your API using your generated OpenAPI document and optional extra context from a Blade view.

### Highlights

[](#highlights)

- Provider‑agnostic backend (configurable): DeepSeek (default), OpenAI (ChatGPT), Google Gemini, Groq, Hugging Face Inference API, Together AI, and OpenAI‑compatible self‑hosted servers (LM Studio, llama.cpp server).
- Chat UI with Markdown + syntax highlighting; Copy action on AI replies; works across light/dark themes.
- Built‑in Request Tester panel (inside Chat) to call any route, auto‑merging Authorization from Swagger Authorize and your extra headers; renders formatted responses.
- Provider chooser appears in Chat if no key is configured, with one‑click guides and copyable .env snippets.
- Edit &amp; Resend: quickly update your last message and resubmit. The backend prunes the replaced turn to keep context clean.
- Attachments: attach text, JSON, image (vision-capable models only), or URL. Text/JSON are added as short context snippets; images are included on user turns for OpenAI-compatible providers.
- Endpoint-aware actions: when an assistant reply includes a heading like `### GET /path`, the UI shows “Open endpoint” and “Try it with this data”. Try It auto-fills parameters/body from your message and executes.
- Exports: download the chat as plain text, Markdown, or JSON (`{ version: "idoc-1", messages: [...] }`).

### Customizing the chat system prompt

[](#customizing-the-chat-system-prompt)

- You can supply your own Markdown file that defines the default system prompt used to shape assistant replies.
- Easiest path: publish and edit the bundled prompt. iDoc will automatically use the published copy if it exists. ```
    php artisan vendor:publish --tag=idoc-prompts
    # Edit resources/vendor/idoc/prompts/chat-system.md
    ```
- Optional override: point to any file by setting the `IDOC_CHAT_SYSTEM_PROMPT` env var or `idoc.chat.system_prompt_md` in config.

### Quick start (DeepSeek default)

[](#quick-start-deepseek-default)

Add to your .env:

```
IDOC_CHAT_ENABLED=true
IDOC_CHAT_PROVIDER=deepseek
IDOC_CHAT_MODEL=deepseek-chat
IDOC_CHAT_BASE_URL=https://api.deepseek.com/v1
DEEPSEEK_API_KEY=your_deepseek_key
```

Reload config/cache:

```
php artisan config:clear && php artisan cache:clear
```

### Other providers (examples)

[](#other-providers-examples)

- OpenAI (ChatGPT) ```
    IDOC_CHAT_ENABLED=true
    IDOC_CHAT_PROVIDER=openai
    IDOC_CHAT_MODEL=gpt-4o-mini
    IDOC_CHAT_BASE_URL=https://api.openai.com/v1
    OPENAI_API_KEY=your_openai_key
    ```
- Google Gemini ```
    IDOC_CHAT_ENABLED=true
    IDOC_CHAT_PROVIDER=google
    IDOC_CHAT_MODEL=gemini-1.5-flash
    IDOC_CHAT_BASE_URL=https://generativelanguage.googleapis.com/v1beta
    GOOGLE_API_KEY=your_google_api_key
    ```
- Groq (OpenAI‑compatible) ```
    IDOC_CHAT_ENABLED=true
    IDOC_CHAT_PROVIDER=groq
    IDOC_CHAT_MODEL=mixtral-8x7b-32768
    IDOC_CHAT_BASE_URL=https://api.groq.com/openai/v1
    GROQ_API_KEY=your_groq_key
    ```
- Hugging Face Inference API (serverless) ```
    IDOC_CHAT_ENABLED=true
    IDOC_CHAT_PROVIDER=huggingface
    IDOC_CHAT_MODEL=Qwen/Qwen2.5-7B-Instruct
    IDOC_CHAT_BASE_URL=https://api-inference.huggingface.co
    HF_API_TOKEN=your_hf_token
    ```
- Self‑hosted (OpenAI‑compatible, e.g., llama.cpp server) ```
    IDOC_CHAT_ENABLED=true
    IDOC_CHAT_PROVIDER=openai
    IDOC_CHAT_BASE_URL=http://127.0.0.1:8000/v1
    IDOC_CHAT_MODEL=qwen2.5-7b-instruct
    IDOC_CHAT_API_KEY=localdev
    ```

Tip: If Chat isn’t required, disable it by setting `IDOC_CHAT_ENABLED=false`.

### Chat route middleware

[](#chat-route-middleware)

- Default: chat is stateless. iDoc removes `web` for chat and adds only throttling (`throttle:60,1`).
- If any iDoc middleware needs session, either remove it from chat via `chat.remove_middleware`, or switch to a session‑backed chat by adding the session trio (EncryptCookies, AddQueuedCookiesToResponse, StartSession) to `chat.middleware`.
- Because `web` may be included via the `idoc` group, iDoc excludes it for chat at group time when you set `chat.remove_middleware`.
- See concise recipes in `config/idoc.php`.

### Capability gating (attachments/vision)

[](#capability-gating-attachmentsvision)

- The UI disables image selection when the current model does not support vision.
- For providers that do not support attachments, the attachment row is hidden.

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

[](#configuration)

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

- `path`This will be used to register the necessary routes for the package.

```
'path' => 'idoc',
```

- `logo`You can specify your custom logo to be used on the generated documentation. A relative or absolute url to the logo image.

```
'logo' => 'https://res.cloudinary.com/ovac/image/upload/h_300,w_380,c_fill,r_30,bo_20px_solid_white/aboust_ey5v1v.jpg',
```

- `title`Here, you can specify the title to place on the documentation page.

```
'title' => 'iDoc API Reference',
```

- `description`This will place a description on top of the documentation.

```
'description' => 'iDoc API specification and documentation.',
```

- `version`Documentation version number.
- `terms_of_service`This is the url to the terms and conditions for use your API.
- `contact`Here you can configure contact information for support.

```
'contact' => [
        'name' => 'API Support',
        'email' => 'iamovac@gmail.com',
        'url' => 'http://www.ovac4u.com'
],
```

- `license`A short and simple permissive license with conditions only requiring preservation of copyright and license notices

```
'license' => [
        'name' => 'MIT',
        'url' => 'https://github.com/ovac/idoc/blob/master/LICENSE.md'
],
```

- `output`This package can automatically generate an Open-API 3.0 specification file for your routes, along with the documentation. This is the file path where the generated documentation will be written to. Default: **public/docs**
- `resources`Locations of external resources, that can be customised for self-hosting if required.

```
'resources' => [
        'fonts' => '//fonts.googleapis.com/css?family=Roboto:400,700',
        'redoc_standalone_js' => 'https://cdn.jsdelivr.net/npm/redoc@2.5.1/bundles/redoc.standalone.js',
        'swagger_css' => 'https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui.css',
        'swagger_ui_js' => 'https://cdn.jsdelivr.net/npm/swagger-ui-dist@5/swagger-ui-bundle.js',
],
```

- `hide_download_button`This section is where you can configure if you want a download button visible on the documentation.
- `router`The router to use when processing the route (can be Laravel or Dingo. Defaults to **Laravel**)
- `servers`The servers array can be used to add multiple endpoints on the documentation so that the user can switch between endpoints. For example, This could be a test server and the live server.

```
'servers' => [
   [
       'url' => 'https://www.ovac4u.com',
       'description' => 'App live server.',
   ],
   [
       'url' => 'https://test.ovac4u.com',
       'description' => 'App test server.',
   ],
],
```

- `tag_groups`This array is used to separate groups that you have defined in little sections in the side menu. If you want to use it, make sure you add all groups because the unadded group will not be displayed.
- `external_description`This option allows you to specify a route name for an external description that will be used in the documentation. If not provided, it will default to the route `idoc.info`. By default, it is set to `idoc.info`.

```
'external_description' => 'idoc.info', // Route name for external description, leave empty to use default description
```

Example usage:

```
'external_description' => 'idoc.info',
```

- `language-tabs`This is where you can set languages used to write request samples. Each item in array is used to generate a request template for a given language. New languages can be added and the existing ones modified after. You can add or edit new languages tabs by publishing the view files and editing them or adding custom view files to:

```
'resources/views/vendor/idoc/languages/LANGUAGE.blade.php',
```

- `security`This is where you specify authentication and authorization schemes, by default the HTTP authentication scheme using Bearer is setting but you can modify it, add others or even define it as null according to the requirements of your project. For more information, please visit [Swagger Authentication](https://swagger.io/docs/specification/authentication/).

```
'security' => [
       'BearerAuth' => [
           'type' => 'http',
           'scheme' => 'bearer',
           'bearerFormat' => 'JWT',
       ],
   ],
```

- `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 [
     //...,

     /*
     * The routes for which documentation should be generated.
     * Each group contains rules defining what routes should be included ('match', 'include' and 'exclude' sections)
     * and rules which should be applied to them ('apply' section).
     */
    'routes' => [
        [
            /*
             * Specify conditions to determine what routes will be parsed in this group.
             * A route must fulfill ALL conditions to pass.
             */
            'match' => [

                /*
                 * Match only routes whose domains match this pattern (use * as a wildcard to match any characters).
                 */
                'domains' => [
                    '*',
                    // 'domain1.*',
                ],

                /*
                 * Match only routes whose paths match this pattern (use * as a wildcard to match any characters).
                 */
                'prefixes' => [
                    'api/*',
                ],

                /*
                 * Match only routes registered under this version. This option is ignored for Laravel router.
                 * Note that wildcards are not supported.
                 */
                'versions' => [
                    'v1',
                ],
            ],

            //...
        ],
    ],
```

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:

```
