alcamo/conf
Composer 安装命令:
composer require alcamo/conf
包简介
Simple reading of conf files from XDG base directories
关键字:
README 文档
README
use alcamo\conf\{Loader, XdgFileFinder}
$conf = (new Loader(new XdgFileFinder('foo')))->Load(
[ 'default.ini', 'conf.ini' ]
);
Now $conf contains an array representing the contents of
$XDG_CONFIG_HOME/foo/default.ini and
$XDG_CONFIG_HOME/foo/conf.ini, where items in the latter replace
items in the former with the same key, if $XDG_CONFIG_HOME is
set. Otherwise, foo/conf.ini is searched as specified in the
XDG Base Directory Specification
use alcamo\conf\{Loader as LoaderBase, XdgFileFinder as XdgFileFinderBase}
class XdgFileFinder extends XdgFileFinderBase
{
public const SUBDIR = 'foo';
}
class Loader extends LoaderBase
{
public const DEFAULT_FILE_PARSER_CLASS = XdgFileFinder::class;
public const CONF_FILES = [ 'default.ini' ];
}
$conf = (new Loader())->Load('conf.ini');
This has exactly the same effect and may be more useful if configurations are loaded from the same subdirectory in many places in the code, in particular when there is a common basic configuration files plus specific configuration files.
use alcamo\conf\{Loader as LoaderBase, XdgFileFinder as XdgFileFinderBase}
class XdgFileFinder extends XdgFileFinderBase
{
public const SUBDIR = 'bar';
}
$cacheFilename = (new XdgFileFinder(null, 'CACHE'))->find('data.json');
Now, $cacheFilename contains $XDG_CACHE_HOME/bar/data.json if
$XDG_CACHE_HOME is set. Otherwise, the path is constructed as
specified in the XDG Base Directory Specification. If the directory
$XDG_CACHE_HOME/bar did not exist, it has been created
automatically.
Supplied interfaces, classes and traits
Interface FileFinderInterface
Interface for configuration file finders to put into a Loader object.
Class XdgFileFinder
Finds config files and other files following the XDG Base Directory Specification.
Interface FileParserInterface
Interface for file parsers to put into a Loader object.
Class IniFileParser
Parser for INI files.
Class JsonFileParser
Parser for JSON files.
Class FileParser
Parser for INI or JSON files, telling the file type from the suffix.
Interface LoaderInterface
Interface implemented by the Loader class.
Class Loader
Contains a file finder and a file parser object and uses them to locate and load file or a nuimber of files.
Interface HavingConfInterface
Class that provides an array with configuration data.
Trait HavingConfTrait
Simple implementation of HavingConfInterface.
alcamo/conf 适用场景与选型建议
alcamo/conf 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 101 次下载、GitHub Stars 达 0, 最近一次更新时间为 2021 年 06 月 30 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「configuration」 「xdg」 「conf」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 alcamo/conf 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 alcamo/conf 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 alcamo/conf 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Configuration component
Nginx configuration files processor.
The PHP media library: media processing and MIME-Type/extension guessing.
Utils to load, parse and work with configuration on Mezzio projects
An abstraction layer over environment variables.
Nginx configuration files processor.
统计信息
- 总下载量: 101
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: Apache-2.0
- 更新时间: 2021-06-30