gap/config

此包的最新版本(v2.0.2)没有提供许可证信息。

Gap Config

v2.0.2 2018-02-28 08:32 UTC

This package is auto-updated.

Last update: 2024-09-22 04:38:56 UTC


README

<?php

use Gap\Config\ConfigBuilder;

$settingDir = '/your/setting/dir';
$cacheFile = '/your/setting/cache-file';
$configBuilder = new ConfigBuilder(
    $settingDir,
    $cacheFile
);

$config = $configBuilder->build();

$debug = $config->bool('debug'); // false

$dbDefaultConfg = $config->config('db')->config('default');

$dbDefaultConfig->str('driver');
$dbDefaultConfig->str('database');
$dbDefaultConfig->str('host');
$dbDefaultConfig->str('username');

$dbDefaultConfig->arr('username');
/*
[
    'driver' => 'mysql',
    'charset' => 'utf8mb4',
    'collation' => 'utf8mb4_unicode_ci',
    'database' => 'db',
    'host' => 'host',
    'username' => 'username',
    'password' => 'passwd'
]
*/

设置目录结构

  • setting/
    • system/ 系统配置
    • custom/ 自定义配置,可以覆盖系统配置
    • local/ 本地配置,可以覆盖自定义和系统配置,被git忽略
    • setting.app.php
    • setting.local.php

配置加载顺序

  1. setting.local.php(必需)
  2. setting.app.php(必需)
  3. system/
  4. custom/
  5. local/