Skip to main content

What Are Environments?

Environments represent different deployment contexts for your API (local, staging, production). The package uses environment configurations to:
  • Generate Postman and Insomnia environment files
  • Inject correct server URLs into OpenAPI specifications
  • Support variable inheritance through parent-child relationships
  • Track resource IDs across CRUD operation chains

Base Environment

Defines shared variables inherited by all environments

Sub-Environments

Specific configs for artisan, local, production

Tracking Variables

Chain CRUD operations using resource IDs

Configuration

Environments are configured in config/openapi.php:

Hierarchical Inheritance

Base Environment

The base environment is the parent for all other environments. It defines:
  • Common variables - Shared across all environments
  • Tracking variables - GLOBAL variables for CRUD chaining
The base environment is never used directly. It only provides defaults for sub-environments.

Sub-Environments

Sub-environments inherit from base and override specific variables:
Used with php artisan serve:
Final Variables:

Inheritance Logic

Tracking Variables

Tracking variables are GLOBAL variables that enable chaining CRUD operations in Postman and Insomnia.

What Are Tracking Variables?

Tracking variables automatically capture resource IDs from create/update operations and use them in subsequent show/update/delete requests. Example Flow:

Configuration

Tracking variables MUST be defined in the base environment only.

Naming Convention

Format: last_{resource_name}_id

How It Works

The generator automatically uses tracking variables for CRUD operations:

Generated Parameter References

For resources with tracking variables:
In Postman/Insomnia:

Placeholder Support

Use ${{placeholderName}} syntax for dynamic values that are replaced during generation.

Available Placeholders

Usage Examples

After Replacement:

Generating Environment Files

Postman Environments

Generated Postman Environment:

Insomnia Environments

Generated Insomnia Workspace:

Adding Custom Environments

1

Define Environment

Add your environment to config/openapi.php:
2

Generate Documentation

The new environment will be included in generated Postman/Insomnia files.
3

Use in HTTP Endpoint

Best Practices

Tracking Variables Location
  • ALWAYS define tracking_variables in the base environment only
  • NEVER define them in sub-environments
  • They are automatically inherited by all sub-environments
Variable Naming
  • Use descriptive names: base_url not just url
  • Follow snake_case: api_key not apiKey
  • Tracking variables: always use last_{resource}_id format
Sensitive Values
  • Use empty strings for secrets: 'api_key' => ''
  • Users fill in values after importing
  • Use env() for development environments
Placeholder Usage
  • Use for project-specific URLs
  • Avoid for user-specific values
  • Test placeholder replacement in generated files

Next Steps

Postman Collections

Learn how environments are used in Postman collections

Configuration Reference

Complete environment configuration options