nmapx / inidister
此包已被废弃且不再维护。未建议替代包。
使用 .dist.ini 架构文件创建根据您环境依赖的 .ini 文件。
1.0.1
2018-01-18 20:36 UTC
Requires
- php: >=7.1
README
Inidister
使用 .dist.ini 架构文件创建根据您环境依赖的 .ini 文件。
Inidister 是管理配置文件的一个完美解决方案。
它的工作方式与 Symfony YAML dist 功能相同 - 它将生成一个新文件(或使用默认值扩展现有文件,您可以选择手动更改这些默认值,而不会再次替换)。
PHP 支持开箱即用的 ini 文件(parse_ini_file())。
要求
- PHP >= 7.1 且带有 composer
安装
使用 Composer
composer require nmapx/inidister
用法
很简单 - 创建一个注册表,然后将一些文件添加到其中。
将注册表附加到 Inidister 对象并执行它。现在您的文件应该在正确的位置。
<?php use Nmapx\Inidister\Application\{ Inidister, Registry }; require __DIR__ . '/../vendor/autoload.php'; $registry = new Registry(); $registry->add(__DIR__ . '/example.dist.ini', __DIR__ . '/example.ini'); $inidister = new Inidister(); $inidister->attach($registry) ->execute();
演示
示例 dist 文件
[example1/nested1] ;add some comments key1 = value1 [example1/nested2] key1 = value1 key2 = value2 ;comment here key3 = value3 [example2] key1 = value1 key2 = value2 ;and here [example3] key1 = value1
基于 dist 的结果
[example1/nested1] key1=value1 [example1/nested2] key1=value1 key2=value2 key3=value3 [example2] key1=value1 key2=value2 [example3] key1=value1
现在您可以将一些带默认值的键添加到 dist 中,然后重新生成输出文件。
只要在架构(dist)中存在键,您的数据就不会从输出文件中消失(或重置为默认值)。
许可
MIT 许可证。有关详细信息,请参阅 LICENSE。