You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
-**Runtime Changes**: Modify configuration values at runtime for testing or dynamic behavior
11
12
-**Helper Functions**: Easy-to-use helper functions for common config operations
@@ -30,22 +31,44 @@ if helpers.has_config('app.name'):
30
31
all_app_config = helpers.get_all_config('app')
31
32
```
32
33
34
+
### JSON Configuration Overrides
35
+
36
+
JSON configuration takes precedence over config files but environment variables still override everything. The `config.json` file is bundled into the application when built and contains non-sensitive settings:
37
+
38
+
-`app.name` → `APP_NAME` in JSON
39
+
-`app.response_number` → `APP_RESPONSE_NUMBER` in JSON
40
+
-`app.logging.level` → `APP_LOGGING_LEVEL` in JSON
41
+
42
+
Example `config.json` file:
43
+
```json
44
+
{
45
+
"APP_NAME": "My Custom App",
46
+
"APP_ENV": "development",
47
+
"APP_DEBUG": true,
48
+
"APP_RESPONSE_NUMBER": 100,
49
+
"APP_MESSAGE": "Hello from the environment!",
50
+
"APP_LOGGING_LEVEL": "DEBUG"
51
+
}
52
+
```
53
+
33
54
### Environment Variable Overrides
34
55
35
-
Environment variables take precedence over config files. Use uppercase and underscores:
56
+
Environment variables take highest precedence over both JSON config and config files. Use uppercase and underscores:
36
57
37
58
-`app.name` → `APP_NAME`
38
59
-`app.response_number` → `APP_RESPONSE_NUMBER`
39
60
-`app.logging.level` → `APP_LOGGING_LEVEL`
40
61
41
-
Example `.env` file:
62
+
Example environment variables:
42
63
```bash
43
-
APP_NAME=My Custom App
44
-
APP_DEBUG=true
45
-
APP_RESPONSE_NUMBER=100
46
-
APP_MESSAGE=Hello from the environment!
64
+
exportAPP_NAME="My Custom App"
65
+
exportAPP_DEBUG=true
66
+
exportAPP_RESPONSE_NUMBER=100
67
+
exportAPP_MESSAGE="Hello from the environment!"
47
68
```
48
69
70
+
**Note:** The bundled `config.json` file provides application defaults and is automatically extracted and cleaned up when the application runs. Environment variables can still be used to override any setting at runtime.
@@ -112,10 +135,13 @@ value = helpers.env('app.name') # Falls back to config if no env var
112
135
## Best Practices
113
136
114
137
1.**Organize by Feature**: Create separate config files for different aspects (database, mail, cache, etc.)
115
-
2.**Use Environment Variables**: For sensitive data and environment-specific settings
116
-
3.**Provide Defaults**: Always provide sensible default values
117
-
4.**Document Settings**: Add comments to explain complex configuration options
118
-
5.**Validate Config**: Add validation for critical configuration values in your application startup
138
+
2.**Use JSON for Non-Sensitive Defaults**: Store application defaults in `config.json` that get bundled with the application
139
+
3.**Use Environment Variables**: For sensitive data and environment-specific settings
140
+
4.**Provide Defaults**: Always provide sensible default values
141
+
5.**Document Settings**: Add comments to explain complex configuration options
142
+
6.**Validate Config**: Add validation for critical configuration values in your application startup
143
+
144
+
**Security Note**: The `config.json` file is bundled into the application and can be viewed by anyone with access to the built executable. Only store non-sensitive configuration in this file. Use environment variables for sensitive data like API keys, passwords, and secrets.
0 commit comments