application.yml and programmatic bean construction via #[Configuration] classes. Both are fully integrated with the dependency-injection container, so any property or bean is available for injection anywhere in your application. This page covers every layer of the system — from the YAML file structure and the #[Value] attribute, through additional property sources, to the || fallback-chain syntax.
application.yml Structure
All externalised properties live inconfig/application.yml (the path is set by the configDirectory option of #[WinterBootApplication]). Winter Boot parses this file at startup and makes every key available to the property context. The reserved top-level keys used by the framework are shown below; custom application keys can live anywhere else in the file.
config/application.yml
Reserved Top-Level Keys
integer
default:"8080"
Port the Swoole HTTP server binds to.
string
default:"127.0.0.1"
Network interface the server listens on. Use
0.0.0.0 to bind all interfaces.string
default:"/"
URL prefix prepended to all mapped routes.
string
Human-readable service name. Exposed by health and metrics endpoints.
string
Machine-readable service identifier used in logs and service-discovery registrations.
string
Semantic version string for the running service.
array
List of datasource definitions. Each entry requires at least
name, url, and driverClass.#[WinterBootApplication] Attribute Options
The entry-point attribute controls how Winter Boot boots your application. All parameters are optional and have sensible defaults.Application.php
Attribute Parameter Reference
Injecting Properties with #[Value]
The#[Value] attribute injects a property from the application context into any bean property or constructor parameter. Reference YAML keys with dot notation inside ${ }.
src/AppConfig.php
Programmatic Bean Configuration
For beans that require construction logic — datasource pools, transaction managers, cache providers, third-party clients — use a#[Configuration] class. Methods annotated with #[Bean] are called once at startup and their return values are registered as managed beans. Winter Boot automatically injects other beans as method parameters.
src/DatabaseConfig.php
Each
#[Bean] method is invoked exactly once. The returned instance is cached in the application context and shared across all injection points — beans are singletons by default.Additional Property Sources
Beyondapplication.yml, Winter Boot supports pluggable PropertySource implementations. Register them in application.yml under the propertySources key and reference their values with $sourceName.key notation.
- Environment Variables
- INI File
- Custom Source
The built-in
EnvPropertySource reads from $_ENV. Register it and reference variables with the $env. prefix:config/application.yml
Fallback Chains with ||
A property value can be a||-separated chain. Winter Boot tries each term from left to right and uses the first present value. This lets you layer sources — environment variable first, INI file second, hard-coded default last — without any PHP code.
config/application.yml
Fallback Chain Rules
Presence and fall-through rules
Presence and fall-through rules
Profiles
Use theprofile parameter of #[WinterBootApplication] to load environment-specific configuration. Winter Boot merges application-{profile}.yml on top of the base application.yml, with profile-specific values taking precedence.
Application.php
config/application-prod.yml
Complete Example
The example below shows a fullapplication.yml combining a custom property source, fallback chains, and all standard Winter Boot keys:
config/application.yml