jdwx/config
最新稳定版本:v1.0.1
Composer 安装命令:
composer require jdwx/config
包简介
A simple configuration library for PHP.
README 文档
README
A simple PHP module for interacting with config files.
This module provides a simple interface to configuration files in a variety of formats:
- .ini
- .json
- .yaml
Installation
You can require it directly with Composer:
composer require jdwx/config
Or download the source from GitHub: https://github.com/jdwx/config.git
Requirements
This library requires PHP 8.0 or later. It has not been tested for compatibility with earlier versions.
Usage
<?php declare( strict_types = 1 ); use JDWX\Config\ConfigDB; use JDWX\Config\IniParser; require 'vendor/autoload.php'; $stDefaults = <<<CFG [foo] bar = baz qux = quux CFG; $defaults = IniParser::fromString( $stDefaults ); $cfg = ConfigDB::fromFile( __DIR__ . '/example.ini', $defaults ); echo "[foo]bar = ", $cfg->get( 'foo', 'bar' )->asString(), "\n"; echo "[foo]qux = ", $cfg->get( 'foo', 'qux' )->asInt(), "\n"; echo "[foo]grault = ", $cfg->get( 'foo', 'grault' )->asString(), "\n";
Stability
This module is stable and has been used in production code. New methods or support for additional file formats may be added in the future, but existing methods should not be changed in a way that breaks existing code without at least a minor version update.
History
This module was originally developed in 2024 to supersede and unify three other existing modules for configuration management.
统计信息
- 总下载量: 156
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2024-05-04