cleup/config 问题修复 & 功能扩展

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

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

cleup/config

最新稳定版本:1.0.3

Composer 安装命令:

composer require cleup/config

包简介

Web application configuration

README 文档

README

Installation

Install the cleup/config library using composer:

composer require cleup/config
Initialization
$configuration = new Cleup\Configuration\Loader([
    'debug' => false,
    'cache' => true,
    'cachePath' => __DIR__ . '/cache/config',
    'configPath' => __DIR__ . '/config',
    'env' => true,
    'envPath' => __DIR__
]);

$configuration->load();
Creating configuration and environment files

config/app.php

return [
    "site_name" =>  'Cleup',
    "is_active" => true,
    "port"   => 80
];

config/modules/articles.php

return [
    "name" =>  'Articles',
    "description" => "This is the articles module"
];

.env (.env.production or .env.local if debugging is enabled)

APP_NAME=Cleup
BOOL_TRUE=true
BOOL_FALSE=false
# Comment
INTIGER=2007
FLOAT=22.122002
Methods
use Cleup\Configuration\Config;
use Cleup\Configuration\Environment\Env;

# Get
// where “app” is the name of the file
Config::get('app.site_name'); // string(Cleup)
// where “modules” is the directory name and “articles” is the file name
Config::get('modules.articles.description'); // string(This is the articles module)
// The default value
Config::get('app.oops', 'Some kind of a default value'); // string(Some kind of a default value)
// Environment
Env::get('APP_NAME');  // string(Cleup);
Env::get('BOOL_TRUE'); // bool(true);
Env::get('INTIGER');   // int(2007);
Env::get('FLOAT');     // float(22.122002);
Env::get('OOPS', 404); // int(404);

# Set - The methods do not change the structure of the underlying configuration and environment files.
Config::set('modules.articles.id', 35);
Env::set('LEVEL', 'Admin');

# Helpers
config('app.site_name') // string(Cleup),
env('APP_NAME')         // string(Cleup),

统计信息

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

GitHub 信息

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

其他信息

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