Skip to content

Commit 84c7093

Browse files
committed
docs: document per-environment configuration
1 parent bc456d6 commit 84c7093

File tree

1 file changed

+21
-2
lines changed

1 file changed

+21
-2
lines changed

src/Web/Documentation/content/main/1-essentials/06-configuration.md

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -118,9 +118,28 @@ final class SlackConnector extends HttpConnector
118118
}
119119
```
120120

121-
## Configuration cache
121+
## Per-environment configuration
122122

123-
During development, Tempest will discover configuration files every time the framework is booted. In a production environment, you should bypass this process to improve the performance by setting the `{txt}{:hl-property:CONFIG_CACHE:}` environment variable to `true`.
123+
Whenever possible, you should have a single configuration file per feature. You may use the `Tempest\env()` function inside that file to reference credentials and environment-specific values.
124+
125+
However, it's sometimes needed to have completely different configurations in development and in production. For instance, you may use S3 for your [storage](../2-features/05-file-storage.md) in production, but use the local filesystem during development.
126+
127+
When this happens, you may create environment-specific configuration files by using the `.<env>.config.php` suffix. For instance, a production-only configuration file could be `storage.prod.config.php`:
128+
129+
```php src/storage.prod.config.php
130+
return new S3StorageConfig(
131+
bucket: env('S3_BUCKET'),
132+
region: env('S3_REGION'),
133+
accessKeyId: env('S3_ACCESS_KEY_ID'),
134+
secretAccessKey: env('S3_SECRET_ACCESS_KEY'),
135+
);
136+
```
137+
138+
## Disabling the configuration cache
139+
140+
During development, Tempest will discover configuration files every time the framework is booted. In a production environment, configuration files are automatically cached.
141+
142+
You may override this behavior by setting the `{txt}{:hl-property:CONFIG_CACHE:}` environment variable to `true`.
124143

125144
```env .env
126145
{:hl-property:CONFIG_CACHE:}={:hl-keyword:true:}

0 commit comments

Comments
 (0)