定制 simplon/config 二次开发

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

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

simplon/config

Composer 安装命令:

composer require simplon/config

包简介

Simple Config Reader

README 文档

README

     _                 _                                __ _       
 ___(_)_ __ ___  _ __ | | ___  _ __     ___ ___  _ __  / _(_) __ _ 
/ __| | '_ ` _ \| '_ \| |/ _ \| '_ \   / __/ _ \| '_ \| |_| |/ _` |
\__ \ | | | | | | |_) | | (_) | | | | | (_| (_) | | | |  _| | (_| |
|___/_|_| |_| |_| .__/|_|\___/|_| |_|  \___\___/|_| |_|_| |_|\__, |
                |_|                                          |___/ 

Simplon Config

Its a simple config file reader which handles namespaced config arrays.

Config file example

$app = [
  'url'      => [
    'service'  => '[URL_SERVICE]',
    'frontend' => '[URL_FRONTEND]',
  ],

  'database' => [
    'mysql' => [
      'localhost' => [
        'server'   => 'localhost',
        'database' => 'some_db',
        'username' => 'rootuser',
        'password' => 'rootuser'
      ]
    ],
  ],
  'email'    => [
    'host' => 'localhost',
    'port' => 25,
  ],
];

Get data from your config file

To safe resources we access the config class via singleton pattern Config::getInstance(). By passing the config file path we inform the class which file we want to read. Now, in order to fetch an actual value we pass an existing config array index as array to getConfigKeys(['url']). As a result we would receive all values which are within the array index of url:

[
  'service'  => '[URL_SERVICE]',
  'frontend' => '[URL_FRONTEND]',
];

Multiple array elements will be chained together. According to that the following example will only return the string value for ['url']['service']:

use Simplon\Config\Config;

$configPath = __DIR__ . '/../../config/common.config.php';

$urlService = Config::getInstance()
->setConfigPath($configPath)
->getConfigByKeys(['url', 'service']);

echo $urlService; // prints "[URL_SERVICE]"

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2012-10-18

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固