Laravel Module Generator

v 1.3.*

Postman Generation

postman:generate — Generate Postman collection

Generate a complete Postman collection for testing your API endpoints.

Signature:

php artisan postman:generate
    {--file= : Path to the YAML schema file}
    {--base-url= : Base URL for API}
    {--prefix= : API prefix}
    {--output= : Output file path}

Options:

  • --file=path/to/file.yaml — Custom YAML file (default: module/models.yaml)
  • --base-url=http://localhost:8000 — Base URL for requests
  • --prefix=api/v1 — API prefix for endpoints
  • --output=module/postman_collection.json — Output file path

Examples:

# Generate with defaults
php artisan postman:generate

# Generate with custom base URL and prefix
php artisan postman:generate --base-url=https://api.myapp.com --prefix=api/v2

# Generate to custom location
php artisan postman:generate --output=exports/api-collection.json

Features:

  • Automatically detects models with image or file fields and generates form-data requests
  • Models without file fields use raw JSON format
  • Includes nested relation data based on nested_requests configuration
  • Generates Bearer token authentication headers
  • Creates example request/response bodies for all CRUD operations

Postman output

  • Postman collection: module/postman_collection.json (or custom path)
    • Import into Postman/Insomnia for manual testing
    • Includes all CRUD endpoints with example bodies
    • Automatically uses form-data for models with file/image fields
    • Uses raw JSON for other models

When generating the Postman collection you can specify a base URL and prefix so request examples match your environment.