kris-ro/php-config 问题修复 & 功能扩展

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

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

kris-ro/php-config

最新稳定版本:v1.0.3

Composer 安装命令:

composer require kris-ro/php-config

包简介

Setup, getter and setter for configuration in PHP applications

README 文档

README

PHP class for managing configuration throughout an application.

Installation

Use composer to install PHP Config.

composer require kris-ro/php-config

Usage

require YOUR_PATH . '/vendor/autoload.php';

use KrisRo\PhpConfig\Config;

# static call
# providing a path (optional) to a folder here will load all json files in the folder
Config::buildConfig('/absolute/path/to/your/folder/with/json/files');

// magic call for debug and salt entries in the config array
Config::debug();
Config::salt();

// setter call
// set method returns the new value
Config::set('database/username', 'k2'); # returns 'k2'

Config::get('database/username'); # returns 'k2'

Initialize as object

// path here is also optional; if provided all json files in that folder will be loaded
new Config('/absolute/path/to/your/folder/with/json/files');

$this->assertEquals('k2', Config::set('database/username', 'k2'));
// verify new value
$this->assertEquals('k2', Config::get('database/username'));

Load json files in specific order

(new Config())
      ->loadConfigFile(/absolut/path/to/first.json')
      ->loadConfigFile(/absolut/path/to/second.json')
      ->loadConfigFile(/absolut/path/to/nth.json');

(new Config())
      ->setConfigPath('/absolute/path/to/your/folder/with/json/files')
      ->loadConfigFile(first-file-to-load.json')
      ->loadConfigFile(second-file-to-load.json')
      ->loadConfigFile(nth-file-to-load.json');

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-27