yaxin/php-config

1.1.0 2020-06-28 07:51 UTC

This package is auto-updated.

Last update: 2024-05-28 16:36:40 UTC


README

php-config is a config file reader, that can read yaml json and php format config file.

Installation

php-config is available via composer. Just add the following code to your composer.json file under required section and execute command composer update or you can run directly:

composer require yaxin/php-config

Usage

Examples

config directory structure

.
├── app.yaml
├── abc.php
├── bcd.yml
├── cde.json
├── info.php
├── regions
│   └── beijing.yml
├── production
|   └── database.yml
├── testing
|   └── database.yml
└── development
    └── database.yml
use Yaxin\PHPConfig\PHPConfig;

$config = new PHPConfig('/path/to/config/path', '/path/to/compile_cache/path', 'production');
$config->get('app.name');
// output is: php-config

$config->get('regions.beijing.name');
// output is: beijing

$config->get('database.default.host');
// output is: 1.2.3.4

$config->get('none.exist.key');
// output is: null

$config->get('none.exist.key', 'php-config');
// output is: php-config

License

MIT