项目作者: Xeloses

项目描述 :
Human-friendly config file parser for PHP
高级语言: PHP
项目地址: git://github.com/Xeloses/human-friendly-config.git
创建时间: 2020-06-30T02:45:54Z
项目社区:https://github.com/Xeloses/human-friendly-config

开源协议:GNU General Public License v3.0

下载


Human-friendly config files support for PHP.

Human-friendly config file parser for PHP

Allows to use config files with pairs Option name = value

Every pair should be on a new line.

Similar to INI files, but without groups.

Also commentaries allowed:

  • # this is a comment
  • // this is a comment too

Usage

Example config file:

  1. # User data:
  2. User name = Suprauser
  3. Address = London, New Avenue, 77
  4. Phone number = 990-123-45-67

Every option name will be converted to valid lower case attribute name where all spaces between words replaced with underscores.

  1. use Xeloses\HumanFriendlyConfig\ConfigFile;
  2. $config = ConfigFile('../conf/user.info');
  3. echo "User: {$config->user_name} ({$config->phone_number}); {$config->address}.";

Change or add new values:

  1. $config->user_name .= 'notRoot';
  2. $config->email = 'suprauser@myhost.com';
  3. $config->save();

Get value with “default” option:

  1. echo 'Age: '.$config->get('age','unknown');

Config can be saved to a new file:

  1. $config->saveAs('../conf/backup/user.info');