yaxin / php-config
PHP 配置读取器
1.1.0
2020-06-28 07:51 UTC
Requires
- php: ^7.2
- ext-json: *
- illuminate/config: ^7.0
- symfony/yaml: ^5.1
Requires (Dev)
- phpunit/phpunit: ^8.5
This package is auto-updated.
Last update: 2024-09-28 17:23:06 UTC
README
php-config
是一个配置文件读取器,可以读取 yaml、json 和 php 格式的配置文件。
安装
php-config
通过 composer 提供。只需将以下代码添加到 composer.json
文件中的 required 部分,并执行命令 composer update
,或者您可以直接运行
composer require yaxin/php-config
用法
示例
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