PHP code example of hopheartsceo / laravel-postman-exporter

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

    

hopheartsceo / laravel-postman-exporter example snippets


use Hopheartsceo\PostmanExporter\Facades\PostmanExporter;

// Generate Postman Collection (default)
$collection = PostmanExporter::generate();

// Generate OpenAPI spec
$openapi = PostmanExporter::generate('openapi');

// Generate and save to file
$path = PostmanExporter::save('/path/to/collection.json');

// Generate and upload to Postman
$result = PostmanExporter::upload('your-api-key');

'grouping' => [
    'enabled'         => true,
    'strategy'        => 'prefix',      // Only 'prefix' strategy supported
    'fallback_folder' => 'general',     // Folder for unprefixed / root routes
],

'responses' => [
    'enabled'         => true,
    'fallback_status' => 200,
    'fallback_body'   => null,
],

   /**
    * @response 200 {"id": 1, "name": "John Doe"}
    * @response {"data": []}
    */
   public function index() { ... }
   

'route_filters' => [
    '> ['_ignition'],   // Exclude these prefixes
    'iddleware
],

'middleware_to_headers_map' => [
    'auth:sanctum' => [
        'Authorization' => 'Bearer {{token}}',
    ],
    'auth:api' => [
        'Authorization' => 'Bearer {{token}}',
    ],
],
bash
php artisan vendor:publish --tag=postman-exporter-config
bash
php artisan postman:export --with-responses