tgrj / tweb_config
minimalistic config system
v1.0.0
2026-03-12 22:50 UTC
Requires
- php: ^7.0|^8.0
Requires (Dev)
- phpunit/phpunit: ^12.0
README
minimalistic config system
About
This is part of the core of my tweb micro framework. It serves as the config for certain other aspects of the modules / package.
Usage
- tweb_config_get(string $key)
- This will get the config value of the given key. This key can be some better readable array-depth like for
[ 'a' => [ 'aa' => 1, 'ab' => 2 ] ]you could use'a.ab'as a key to get the config value2. There is a default config (tweb.conf.php) in the modules src folder, By default you can createconfig/tweb.conf.phprelative from the project path. It should return an array. This is able to overwrite the default values, but you can also have your own config keys and values. By overwriting the global variables$TWEB_CONFIG_PATHand$TWEB_CONFIG_FILEyou can define in which folder the user config is stored. You should change these values before callingtweb_config()for the first time.
- This will get the config value of the given key. This key can be some better readable array-depth like for
- tweb_config_set(string $key, mixed $value)
- Normally not to use during runtime, but tests only. But maybe there are situations where you want to alter the config during runtime. The config won't be saved, though.
By default the path getcwd() . '/src/config/tweb.conf.php' is searched for user conf overwrites. You could overwrite it during runtime with tweb_config_set() ... eh, so maybe this function can be usefull during runtime, I guess. Just use it like you want. Hope this will help.