unity / config
Extensible configuration manager for PHP projects that uses dot notation and supports json, ini, array based and many more common formats
Requires
- make/accessible: ^0.1.0
- unity/container: ^0.1.0
- unity/notator: ^0.1.0
- unity/support: ^0.1.0
Requires (Dev)
- mikey179/vfsstream: ^1.6
- mustangostang/spyc: ^0.6.2
- phpunit/phpunit: ^6.4
This package is auto-updated.
Last update: 2020-01-12 18:58:47 UTC
README
An extensible configuration manager for PHP projects.
Get started managing your configurations.
Features
- Array access
- Dot notation access
- Configurations cache
- Auto driver detection
- Runtime modification
Supported drivers
Installation
composer require unity/config
Usage
You have the follow configuration file: configs/db.php in your project folder containing the bellow configurations:
<?php return [ 'user' => 'root', 'psw' => 'toor', 'db' => 'example', 'host' => 'localhost' ];
and you want to manage these configurations, thats what you need to do:
<?php require "vendor/autoload.php"; $config = (new ConfigManager()) ->setSource('configs') ->build();
Now, to access a configuration you can use the $config->get()
, e.g.:
echo $config->get('db.user');
Or in a more simple way, using array access:
echo $config['db']['user'];
Both methods will have the same output:
root
Ask your self, is it easy???
Contributing
We will be really thankful if you make a fork, make your changes and send a pull request!
Credits
License
The Unity/Config is licensed under the MIT license. See license file for more information.