funco/econfig

Maintainers

Details

gitee.com/funco/Config

V1.0.2 2018-05-11 18:27 UTC

This package is not auto-updated.

Last update: 2025-05-04 08:49:14 UTC


README

Description

为PHP项目提供Config读取和更改支持。 路径以英文句号'.'分割

Software Architecture

  • docs
  • src
    • Config.php - 读取配置类
    • config.php - 默认读取的配置
  • LICENSE
  • README.md

Installation

  1. git clone https://gitee.com/funco/Config.git

Instructions

  1. $config = new Config();
  2. $config->get();
  3. $config->set(, );

Example

假设config.php内容如下

<?php
return [
    'MYSQL' => [
        'HOST' => '127.0.0.1',
        'PORT' => 3306,
    ],

    'VERSION' => '1.0',
];

则调用过程如下

$config = new Config(__DIR__ . '../config.php');
echo 'mysql: ' . $config->get('MYSQL.HOST') . ':' . $config->get('MYSQL.PORT') . PHP_EOL;
echo 'version: ' . $config->get('VERSION');

上述程序输出结果如下

mysql: 127.0.0.1:3306
version: 1.0

Note

  1. 默认文件是Config类同目录下的config.php
  2. 建议使用DIR获取当前文件所处绝对路径,再连接config相对当前路径的绝对目录

Contact

  1. 码云给我账号私信
  2. qq: 1136223237
  3. email: linhongzhao321@hotmail.com