olegv / config
Library for configuration and hiding secret data
v1.1.1
2025-03-11 04:19 UTC
Requires
- php: ^8.2
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^11.0
This package is auto-updated.
Last update: 2025-04-18 12:35:25 UTC
README
Library for configuration and hiding secret data
Features
- lightweight
- dependency-free
- 100% test coverage
- phpstan max lvl
- phpstan full strict rules
Install
composer require olegv/config
Usage
- Create secret file somewhere(
$path_to_secret_file
), it must return array<string, string>, for example:<?php $secret = [ 'very_secret' => 'your_secret_key_here2', ]; return $secret;
- Create file with config array, example:
<?php $config_array = [ 'secret' => $secret['very_secret'], 'not_secret' => [ 'data1', 'data2', 'data3', 'secret' => $secret['very_secret'], ], ]; $config = new Config($path_to_secret_file, $config_array);
- If you need get secret data:
$secret_lvl1 = $config['secret']->getValue(); $secret_lvl2 = $config['not_secret']['secret']->getValue();