PHP code example of nutandc / laravel-postman-generator

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

    

nutandc / laravel-postman-generator example snippets


use Nutandc\PostmanGenerator\Attributes\EndpointDoc;

#[EndpointDoc(
    summary: 'List users',
    tags: ['Users'],
    auth: 'bearer',
    headers: [
        ['name' => 'X-Request-ID', 'value' => '{{request_id}}', '   ],
)]
public function index() {}

'postman' => [
    'grouping' => [
        'strategy' => 'name', // uri | name | none
        'name_separator' => '.',
        'uri_depth' => 1,
        'strip_prefixes' => ['api'],
        'fallback' => 'General',
    ],
],

'scan' => [
    'fixes' => ['_debugbar', '__clockwork', 'log-viewer'],
    'exclude_route_names' => ['debugbar.', 'clockwork.', 'log-viewer.'],
],

return [
    'base_url' => env('POSTMAN_GENERATOR_BASE_URL', env('APP_URL', 'http://localhost')),
    'headers' => [
        'default' => [
            ['name' => env('POSTMAN_GENERATOR_HEADER_ACCEPT_NAME', 'Accept'), 'value' => env('POSTMAN_GENERATOR_HEADER_ACCEPT_VALUE', 'application/json')],
        ],
        'json' => [
            ['name' => env('POSTMAN_GENERATOR_HEADER_CONTENT_TYPE_NAME', 'Content-Type'), 'value' => env('POSTMAN_GENERATOR_HEADER_CONTENT_TYPE_VALUE', 'application/json'), 'tadataProvider::class,
    ],
    'auth' => [
        'default' => 'bearer',
    ],
    'responses' => [
        'auto_from_request' => env('POSTMAN_GENERATOR_RESPONSE_AUTO_FROM_REQUEST', true),
        'default_status' => env('POSTMAN_GENERATOR_RESPONSE_DEFAULT_STATUS', 200),
        'default_description' => env('POSTMAN_GENERATOR_RESPONSE_DEFAULT_DESCRIPTION', 'OK'),
    ],
    'postman' => [
        'use_base_url_variable' => true,
        'variables' => [
            'base_url' => env('POSTMAN_GENERATOR_POSTMAN_BASE_URL'),
            'token' => env('POSTMAN_GENERATOR_POSTMAN_TOKEN'),
            'api_key' => env('POSTMAN_GENERATOR_POSTMAN_API_KEY'),
        ],
        'environments' => [
            'local' => [
                'base_url' => env('POSTMAN_GENERATOR_ENV_LOCAL_BASE_URL'),
                'token' => env('POSTMAN_GENERATOR_ENV_LOCAL_TOKEN'),
                'api_key' => env('POSTMAN_GENERATOR_ENV_LOCAL_API_KEY'),
            ],
        ],
    ],
];

'scan' => [
    's' => ['Internal'],
    ',
bash
php artisan vendor:publish --tag=postman-generator-config
bash
php artisan postman:generate
bash
php artisan postman:generate --format=postman
php artisan postman:generate --format=openapi