定制 nmapx/inidister 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

nmapx/inidister

最新稳定版本:1.0.1

Composer 安装命令:

composer require nmapx/inidister

包简介

Use .dist.ini schema files to create .ini depending on your environment.

README 文档

README

Packagist Latest Stable Version License

Inidister

Use .dist.ini schema files to create .ini depending on your environment.

Inidister is a perfect solution to manage your config files.

It works in the same way as Symfony YAML dist functionality - it will produce a new file (or extend existing one with new data using default values which you can change manually and it won't be replaced again).

PHP support ini files out of the box (parse_ini_file()).

Requirements

  • PHP >= 7.1 with composer

Installation

using Composer

composer require nmapx/inidister

Usage

It's simple - create a registry, then add some files to it.

Attach the registry to Inidister object and execute it. You file(s) should be in place now.

<?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();

Demo

Example dist file:

[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

Result based on dist:

[example1/nested1]
key1=value1

[example1/nested2]
key1=value1
key2=value2
key3=value3

[example2]
key1=value1
key2=value2

[example3]
key1=value1

Now you can add some keys with default values to the dist, then regenerate the output file.

Your data won't disappear (or reset to default) from the output file as long as the key exist in the schema (dist).

License

MIT License. Check LICENSE for details.

统计信息

  • 总下载量: 798
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 2
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2015-11-02