codememory/global-config

v1.1.3 2021-09-04 12:46 UTC

This package is auto-updated.

Last update: 2024-09-04 19:02:43 UTC


README

安装

composer require codememory/global-config

命令

  • g-config:init 初始化配置
  • g-config:merge 合并配置到一个配置文件中
    • 选项
      • --all 合并整个配置
      • --configPath={path} 合并特定路径的配置
      • --backup={before|after} 在合并前/后创建配置备份
  • g-config:init-from-backup 从备份文件初始化配置
  • g-config:backup 创建全局配置的备份

GlobalConfig 方法

  • setPath(): GlobalConfigInterface 设置存储配置的路径

    • string $path
  • setFilename(): GlobalConfigInterface 设置配置文件的名称

    • string $filename
  • setBackupFilename(): GlobalConfigInterface 设置备份文件的名称

    • string $filename
  • getPath(): string 返回全局配置的路径

  • getFilename(): string 返回配置文件的名称

  • getExtension(): string 返回配置文件的扩展名

  • getBackupFilename(): string 返回备份文件的名称

  • get(): mixed 通过键获取值

    • string $keys
  • getAll(): array 获取整个全局配置

  • exist(): bool 检查全局配置文件是否存在

使用示例

<?php
// console.php

use Codememory\Components\GlobalConfig\GlobalConfig;
use Symfony\Component\Console\Application;
use Codememory\Components\GlobalConfig\Commands\InitConfigCommand;

require_once 'vendor/autoload.php';

GlobalConfig::setPath('.config/')::setFilename('.cdm.json');

$application = new Application();

$application->add(new InitConfigCommand());

$application->run();
$ php console.php g-config:init

Created: .config/.cdm.json