lawondyss/config
Composer 安装命令:
composer require lawondyss/config
包简介
Base class for creating own class of configuration. Better than a associative array :-)
README 文档
README
Base class for creating own class of configuration. Better than a associative array :-)
Install
Over Composer
composer require lawondyss/config
Usage
class DbConfig extend Lawondyss\Config { public string $driver; public string $host; public string $database; public string $username; public string $password; public string $charset; } $dbConfig = DbConfig::fromArray([ 'driver' => 'mysqli', 'host' => 'localhost', 'database' => 'example', 'username' => 'root', 'password' => 'root', 'charset' => 'utf8' ]);
Simple get and set individual option.
$charset = $dbConfig->charset; $dbConfig->charset = 'latin1';
Is implemented array access.
$pass = $dbConfig['password']; $dbConfig['password'] = '*****';
If you want default values, then defined in class.
class DbConfig extend Lawondyss\Config { public string $driver = 'mysqli'; public string $host = 'localhost'; public string $database; public string $username; public string $password; public string $charset = 'utf8'; } $defaultConfig = new DbConfig;
Is possible "merge" with a customized options.
$lipsumDbConfig = $defaultConfig->withOptions([ 'database' => 'lipsum', 'username' => 'lorem', 'password' => 'ipsum', ]);
If another code use options as associative array:
$dibi = new Dibi\Connection($lipsumDbConfig->toArray());
License
MIT
统计信息
- 总下载量: 2.57k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 3
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-06-03