devuri / config
A lightweight configuration management library for PHP applications.
Installs: 1 314
Dependents: 1
Suggesters: 0
Security: 0
Stars: 1
Watchers: 1
Forks: 0
Open Issues: 0
Requires
- php: ^7.4 || ^8.0
- dflydev/dot-access-data: ^3.0
- symfony/filesystem: 5.4.38
Requires (Dev)
- 10up/phpcs-composer: dev-master
- phpstan/phpstan: ^1.8
- phpstan/phpstan-strict-rules: ^1.3
- phpunit/phpunit: ^9.5
- symfony/var-dumper: ^5.4
- vimeo/psalm: ^4.24 || ^5.0
README
SimpleConfig is a lightweight PHP configuration management library designed to provide an easy and flexible way to handle configuration settings. It leverages dflydev/dot-access-data
for convenient access to nested configuration values using dot notation.
Features
- Easy loading and merging of configuration files.
- Environment-specific configuration overrides.
- Simple dot notation for accessing nested configuration values.
- Optional caching mechanism to enhance performance.
Installation
Use Composer to install SimpleConfig into your project:
composer require devuri/config
Usage
Basic Usage
use Urisoft\SimpleConfig; // Define your configuration path and allowed files $configPath = __DIR__ . '/config'; $allowedFiles = ['app', 'database']; // Instantiate the SimpleConfig object $config = new SimpleConfig($configPath, $allowedFiles, 'production', 'path/to/configCache.php'); // Access configuration values $appName = $config->get('app.name'); $dbHost = $config->get('database.connections.mysql.host');
Setting Configuration Values
// Set a new configuration value $config->set('app.timezone', 'UTC'); // Retrieve the newly set value echo $config->get('app.timezone'); // Outputs: UTC
Clearing Cache
// Manually clear the configuration cache $config->clearCache();
Contributing
Please submit pull requests or create issues for any features, fixes, or improvements.
License
Licensed under the MIT License. See the LICENSE file for details.