PHP code example of gungcahyadipp / auto-docs

1. Go to this page and download the library: Download gungcahyadipp/auto-docs library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gungcahyadipp / auto-docs example snippets


return [
    'api_path' => env('AUTODOCS_API_PATH', 'api'),
    'api_domain' => null,

    'info' => [
        'version' => env('API_VERSION', '1.0.0'),
        'description' => null, // Loaded from markdown file
    ],

    'description_file' => base_path('autodocs/description.md'),

    'ui' => [
        'title' => env('APP_NAME', 'API Documentation'),
        'theme' => 'dark', // 'light', 'dark', 'system'
        'layout' => 'responsive',
    ],

    'security' => [
        'type' => 'bearer',
        'format' => 'JWT',
    ],

    'docs_path' => base_path('autodocs'),
    'description_strategy' => 'file', // 'file', 'merge', 'fallback'
];

/**
 * @unauthenticated
 */
public function login(Request $request) { ... }

// config/autodocs.php
'security' => [
    'type' => 'apiKey',
    'in' => 'header',
    'name' => 'X-API-Key',
],

'security' => null,

// app/Http/Controllers/Api/V1/UserController.php

namespace App\Http\Controllers\Api\V1;

class UserController extends Controller
{
    public function store(StoreUserRequest $request)
    {
        // Your logic here — NO PHPDoc needed for description
        return new UserResource(User::create($request->validated()));
    }
}

/**
 * @unauthenticated
 */
public function login(LoginRequest $request)
{
    // Description comes from autodocs/AuthController/login.md
    // @unauthenticated still works from PHPDoc
}

// config/autodocs.php
'extensions' => [
    App\Docs\MyCustomExtension::class,
],

use Dedoc\Scramble\Scramble;

Scramble::registerExtension(MyTypeToSchemaExtension::class);
Scramble::registerExtension(MyOperationExtension::class);
bash
php artisan vendor:publish --tag=autodocs-config
bash
php artisan vendor:publish --tag=autodocs-description
bash
php artisan vendor:publish --tag=autodocs
bash
   php artisan autodocs:generate
   
bash
php artisan autodocs:generate
bash
# Generate for all API routes
php artisan autodocs:generate

# Only generate for v2 routes
php artisan autodocs:generate --api-path=api/v2

# Regenerate all (overwrite existing)
php artisan autodocs:generate --force