PHP code example of alagiesinghateh / laravel-docmaker

1. Go to this page and download the library: Download alagiesinghateh/laravel-docmaker 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/ */

    

alagiesinghateh / laravel-docmaker example snippets


return [
    'output_dir' => storage_path('docs/api'),
    
    'controller_paths' => [
        app_path('Http/Controllers/API'),
        app_path('Http/Controllers/Api'),
    ],
    
    'web_interface' => [
        'enabled' => true,
        'route_prefix' => 'api-docs',
        'middleware' => ['web', 'api-docs'],
    ],
    
    'security' => [
        'ip_whitelist' => ['127.0.0.1', '::1'],
        'restricted_paths' => [],
    ],
    
    'allowed_users' => [],
    
    'middleware' => [
        'detect' => true,
        'auth_middleware' => ['auth', 'auth:api', 'auth:sanctum'],
        'security_schemes' => [
            'auth' => 'bearer',
            'auth:api' => 'bearer',
            'auth:sanctum' => 'bearer',
        ],
        'exclude' => ['web', 'throttle', 'bindings'],
    ],
    
    'backup' => [
        'max_backups' => 10,
    ],
    
    'defaults' => [
        'method' => 'GET',
        'path' => '/api/endpoint',
        'name' => 'Untitled Endpoint',
        'group' => 'General',
    ],
];

/**
 * @api {GET} /api/users Get Users
 * @apiName GetUsers
 * @apiGroup User
 * @apiDescription Retrieve a list of all users
 * 
 * @apiParam {String} [page] Optional page number
 * @apiParam {String} [per_page] Optional items per page
 * 
 * @apiSuccess {Object[]} data Array of users
 * @apiSuccess {Number} data.id User ID
 * @apiSuccess {String} data.name User name
 * @apiSuccess {String} data.email User email
 * 
 * @apiSuccessExample {json} Success-Response:
 *     HTTP/1.1 200 OK
 *     {
 *         "data": [
 *             {
 *                 "id": 1,
 *                 "name": "John Doe",
 *                 "email": "[email protected]"
 *             }
 *         ]
 *     }
 * 
 * @apiErrorExample {json} Error-Response:
 *     HTTP/1.1 500 Internal Server Error
 *     {
 *         "error": "Server error occurred"
 *     }
 */
public function index()
{
    // Controller logic
}

// config/api-doc-generator.php
'security' => [
    'ip_whitelist' => ['192.168.1.100', '10.0.0.0/24'],
    'restricted_paths' => ['internal', 'admin'],
],

'allowed_users' => [
    '[email protected]',
    '[email protected]',
],

class UserController extends Controller
{
    public static $apiParams = [
        'custom_param' => [
            'type' => 'string',
            '

/**
 * @api {POST} /api/users Create User
 * @apiName CreateUser
 * @apiGroup User
 * @apiDescription Create a new user account
 * 
 * @apiParam {String} name User's full name
 * @apiParam {String} email User's email address
 * @apiParam {String} password User's password
 * 
 * @apiAuth bearer
 * @apiMiddleware auth:api
 */
public function store(CreateUserRequest $request)
{
    // Your controller logic
}

class CreateUserRequest extends FormRequest
{
    public function rules()
    {
        return [
            'name' => '    }
}
bash
php artisan vendor:publish --provider="Alagiesinghateh\LaravelApiDocGenerator\ApiDocGeneratorServiceProvider" --tag="config"
bash
php artisan vendor:publish --provider="Alagiesinghateh\LaravelApiDocGenerator\ApiDocGeneratorServiceProvider" --tag="views"
bash
# Regenerate annotations for all controllers
php artisan singhateh:annotate:regenerate

# Regenerate for specific directory
php artisan singhateh:annotate:regenerate --path=Http/Controllers/API

# Cross-check without modifying files
php artisan singhateh:annotate:regenerate --cross-check

# Force regenerate all annotations
php artisan singhateh:annotate:regenerate --force
bash
# List available backups
php artisan singhateh:backups:list

# Restore from latest backup
php artisan singhateh:backups:restore

# Restore specific backup
php artisan singhateh:backups:restore filename=api-docs_2023-12-15_143022.json
bash
php artisan vendor:publish --provider="Alagiesinghateh\LaravelApiDocGenerator\ApiDocGeneratorServiceProvider" --tag="views"