承接 nimayneb/advini 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

nimayneb/advini

Composer 安装命令:

composer require nimayneb/advini

包简介

Advanced INI reader

README 文档

README

Advanced INI file reader for PHP.

Problem:

You cannot define and read deeper array structures with internal "parse_ini_file" implementation:

[group1]
property1 = value1
property2 = value2
property3 = value3

[group2]
property1 = value1
property2 = value2
property3 = value3

"Advini" extends the internal "parse_ini_file" with several ingredients.

It supports:

  • defining complex keys and sections

     category/property = value
  • importing any INI file

     property = @import[ default.ini ]
  • including constants (from INI file)

     property = << key >> 
  • calling methods before setting

     property:sha1 = geheim1234 

Defining complex keys and sections

Usage:

[{key1}/{key2}(...)]
key3/key4(...) = value

PHP:

use JBR\Advini\Advini;

$ini = new Advini();

$configuration = $ini->getFromFile("local.ini");
var_dump($configuration);

INI:

[category/subcategory]
key = value

Resulted output:

array(
    "category" => array(
        "subcategory" => array(
            "key" => "value"
        )
    )
)

Importing any INI file

Usage:

{key} = @import[ [file] ]

PHP:

use JBR\Advini\Advini;
 
$ini = new Advini();
$configuration = $ini->getFromFile("local.ini");
var_dump($configuration);

INI "local.ini":

category = @import[ import.ini ]

INI "import.ini":

[subcategory]
key = value

Resulted output:

array(
    "category" => array(
        "subcategory" => array(
            "key" => "value"
        )
    )
)

Including constants

Usage:

{key} = << [constant] >>

PHP:

use JBR\Advini\Advini;
use JBR\Advini\Instructor\ConstantInstructor;

$ini = new Advini();
$const = $ini->getInstructor(ConstantInstructor::class);
$const->setConstantsFromFile("constants.ini");
$configuration = $ini->getFromFile("local.ini");
var_dump($configuration);

INI "constants.ini":

[category/subcategory]
key = value

INI "local.ini":

[category/subcategory]
key = << key >>

Resulted output:

array(
    "category" => array(
        "subcategory" => array(
            "key" => "value"
        )
    )
)

Calling methods before setting

Usage:

{key}:{method}(...) = {value}

PHP:

use JBR\Advini\Advini;
use JBR\Advini\Methods\Base;

$ini = new Advini(new Base());

try {
    $configuration = $ini->getFromFile("local.ini");
    var_dump($configuration);
} catch (AdviniException $e) {
    echo $e->getMessage();
}

INI "local.ini":

[category/subcategory]
key1:integer = "foobar"
key2:string = 123
key3:md5 = "secret"

Resulted output:

array(
    "category" => array(
        "subcategory" => array(
            "key1" => 0,
            "key2" => "123",
            "key3" => "5ebe2294ecd0e0f08eab7690d2a6ee69"
        )
    )
)

Or calling by sections:

Usage:

[{section}:{method}]
{key} = {value}

INI "local.ini":

[category/subcategory:serialize]
key1:integer = "foobar"
key2:string = 123
key3:md5 = "secret"

Resulted output:

array(
    "category" => array(
        "subcategory" => "a:3:{s:4:"key1";i:0;s:4:"key2";s:3:"123";s:4:"key3";s:32:"5ebe2294ecd0e0f08eab7690d2a6ee69";}"
    )
)

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: BSD-3-Clause
  • 更新时间: 2016-01-22

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固