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 inconfig/openapi.php:
Hierarchical Inheritance
Base Environment
Thebase 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 frombase and override specific variables:
- Artisan
- Local
- Production
Used with Final Variables:
php artisan serve: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
- With Tracking
- Without Tracking
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
- Server URLs
- Environment Variables
Generating Environment Files
Postman Environments
Insomnia Environments
Adding Custom Environments
1
Define Environment
Add your environment to
config/openapi.php:2
Generate Documentation
3
Use in HTTP Endpoint
Best Practices
Tracking Variables Location
- ALWAYS define
tracking_variablesin thebaseenvironment only - NEVER define them in sub-environments
- They are automatically inherited by all sub-environments
Variable Naming
- Use descriptive names:
base_urlnot justurl - Follow snake_case:
api_keynotapiKey - Tracking variables: always use
last_{resource}_idformat
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