chrissileinus/config-php
Composer 安装命令:
composer require chrissileinus/config-php
包简介
A storage to hold the config of an app. It ist mainly static but as a Singleton with integrated interfaces ArrayAccess, Serializable, JsonSerializable, IteratorAggregate and Traversable.
README 文档
README
A storage to hold the config of a app. It ist mainly static but as a Singleton I have integrated the interfaces ArrayAccess, Serializable, JsonSerializable, IteratorAggregate and Traversable.
Why
There was a need for a small class that is able to read the config from serval inputs and files so that it is stored in a way that it is globally accessible with serval interfaces.
Usage
Config\Storage::integrate( // default values [ 'database' => [ 'host' => "localhost", 'port' => 3306, 'name' => "databasename", 'user' => "username", 'pass' => "fdsgsdgs", ], 'log' => [ 'timezone' => "UTC", 'console' => [ 'level' => Log\Level::NONE, 'ignore' => [], ] ] ], // default value get replaced by values from config files. '/etc/App/*.yaml', '/etc/App/*.json' ); $dbConfig = Config\Storage::getInstance()['database']; $db = new PDO("mysql:host={$dbConfig['host']};port={$dbConfig['port']};dbname={$dbConfig['name']}", $dbConfig['user'], $dbConfig['pass']);
统计信息
- 总下载量: 28
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 8
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2021-11-05