kmapidocvendor/laravel-api-docs

There is no license information available for the latest version (dev-development) of this package.

A Laravel package for generating API documentation

dev-development 2025-06-06 06:53 UTC

This package is auto-updated.

Last update: 2025-06-06 06:54:23 UTC


README

A simple and developer-friendly Laravel package for auto-generating API documentation directly from your Laravel routes, views, and controller metadata.

๐Ÿš€ Features

  • Automatically scans your routes and generates documentation
  • Artisan command to generate docs
  • Blade view integration for web-based display
  • Easy customization by publishing views

๐Ÿ“ฆ Installation

Step 1: Add Local Repository

If you're developing this package locally from a packages/ directory, add the following to your root project's composer.json:

"repositories": [
  {
    "type": "path",
    "url": "packages/KmApiDocVendor/LaravelApiDocs"
  }
]

Step 2: Require the Package

Run the following command from your Laravel project root:

composer require kmapidocvendor/laravel-api-docs:@dev
composer dump-autoload

Step 3: Register the Service Provider (if not using auto-discovery)

If your Laravel version is below 5.5 or you're not using auto-discovery, add the provider manually to config/app.php:

'providers' => [
    // ...
    KmApiDocVendor\LaravelApiDocs\ApiDocsServiceProvider::class,
],

Step 4: Publish the Views (optional)

To customize the documentation UI:

php artisan vendor:publish --provider="KmApiDocVendor\LaravelApiDocs\ApiDocsServiceProvider"

This will publish the view files to:

resources/views/vendor/kmapidocs/

โš™๏ธ Usage

1. Generate the Documentation

Use the artisan command to generate API documentation:

php artisan kmapidoc:generate

This will scan your routes/controllers and create structured docs.

2. View Documentation in the Browser

Once generated, you can view the documentation at:

http://your-app.test/api-docs

The view is rendered via:

$this->loadViewsFrom(__DIR__.'/resources/views', 'kmapidocs');

๐Ÿ›  Customizing the View

If you published the views, you can customize the layout or design:

resources/views/vendor/kmapidocs/api-docs.blade.php

๐Ÿ“‚ Project Structure

packages/
โ””โ”€โ”€ KmApiDocVendor/
    โ””โ”€โ”€ LaravelApiDocs/
        โ”œโ”€โ”€ src/
        โ”‚   โ”œโ”€โ”€ ApiDocsServiceProvider.php
        โ”‚   โ””โ”€โ”€ Console/
        โ”‚       โ””โ”€โ”€ GenerateDocsCommand.php
        โ”œโ”€โ”€ resources/
        โ”‚   โ””โ”€โ”€ views/
        โ”‚       โ””โ”€โ”€ api-docs.blade.php
        โ””โ”€โ”€ routes/
            โ””โ”€โ”€ web.php

๐Ÿงช Compatibility

  • Laravel Versions Supported: ^8.0, ^9.0, ^10.0, ^11.0, ^12.0
  • PHP Version Required: ^8.0

๐Ÿค Contributing

Feel free to fork, improve, and send a pull request.
All contributions are welcome and appreciated!

๐Ÿ“„ License

MIT License ยฉ Keshab Chandra Mandal