jelix/inifile 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

jelix/inifile

Composer 安装命令:

composer require jelix/inifile

包简介

classes to read and modify ini files by preserving comments and empty lines

关键字:

README 文档

README

Some classes to read and modify ini files by preserving comments, empty lines.

They supports sections and array values. You can also merge sections, merge two ini files, and rename some values or sections.

installation

You can install it from Composer. In your project:

composer require "jelix/inifile"

Usage

The \Jelix\IniFile\IniModifier class allows to read an ini file, to modify its content, and save it by preserving its comments and empty lines.

Don't use this class to just read content. Use instead \Jelix\IniFile\Util or parse_ini_file() for this purpose, it's more efficient and performant.

$ini = new \Jelix\IniFile\IniModifier('myfile.ini');

// setting a parameter.  (section_name is optional)
$ini->setValue('parameter_name', 'value', 'section_name');

// retrieve a parameter value. (section_name is optional)
$val = $ini->getValue('parameter_name', 'section_name');

// remove a parameter
$ini->removeValue('parameter_name', 'section_name');


// save into file

$ini->save();
$ini->saveAs('otherfile.ini');

// importing an ini file into an other
$ini2 = new \Jelix\IniFile\IniModifier('myfile2.ini');
$ini->import($ini2);
$ini->save();

// merging two section: merge sectionSource into sectionTarget and then 
// sectionSource is removed
$ini->mergeSection('sectionSource', 'sectionTarget');

It supports also array values (indexed or associative) like :

foo[]=bar
foo[]=baz
assoc[key1]=car
assoc[otherkey]=bus

Then in PHP:

$ini = new \Jelix\IniFile\IniModifier('myfile.ini');

$val = $ini->getValue('foo'); // array('bar', 'baz');
$val = $ini->getValue('assoc'); // array('key1'=>'car', 'otherkey'=>'bus');

$ini->setValue('foo', 'other value', 0, '');
$val = $ini->getValue('foo'); // array('bar', 'baz', 'other value');

$ini->setValue('foo', 'five', 0, 5);
$val = $ini->getValue('foo'); // array('bar', 'baz', 'other value', 5 => 'five');


$ini->setValue('assoc', 'other value', 0, 'ov');
$val = $ini->getValue('assoc'); // array('key1'=>'car', 'otherkey'=>'bus', 'ov'=>'other value');

After saving, the ini content is:

foo[]=bar
foo[]=baz
assoc[key1]=car
assoc[otherkey]=bus

foo[]="other value"
foo[]=five
assoc[ov]="other value"

Note: the result can be parsed by parse_ini_file().

See the class to learn about other methods and options.

The \Jelix\IniFile\MultiIniModifier allows to load two ini files at the same time, where the second one "overrides" values of the first one.

The \Jelix\IniFile\IniModifierArray allows to load several files at the same time, and to manage their values as if files were merged.

The \Jelix\IniFile\Util contains simple methods to read, write and merge ini files. These are just wrappers around parse_ini_file().

jelix/inifile 适用场景与选型建议

jelix/inifile 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 132.86k 次下载、GitHub Stars 达 6, 最近一次更新时间为 2015 年 06 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「ini」 「files」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 jelix/inifile 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 jelix/inifile 我们能提供哪些服务?
定制开发 / 二次开发

基于 jelix/inifile 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

  • Stars: 6
  • Watchers: 2
  • Forks: 3
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-2.1
  • 更新时间: 2015-06-01