承接 marek-baron/config 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

marek-baron/config

最新稳定版本:0.0.1

Composer 安装命令:

composer require marek-baron/config

包简介

Lightweight PHP configuration library.

README 文档

README

CI

Lightweight, dependency-free PHP configuration library.

Features

  • Simple key access using dot notation (db.host)
  • Immutable config (with() returns a cloned instance)
  • Merge multiple config sources via ConfigAggregator
  • Provider support for files, callables, classes, or arrays
  • No external dependencies

Installation

composer require marek-baron/config

Config example

$config = new Config([
'db' => ['host' => 'localhost', 'port' => 3306],
'app' => ['debug' => false],
]);

echo $config->get('db.host');
$newConfig = $config->with('app.debug', true); //Immutable!

var_dump($config->get('app.debug'));     // false
var_dump($newConfig->get('app.debug'));  // true

ConfigAggregator example

use MarekBaron\Config\ConfigAggregator;

$aggregator = new ConfigAggregator([
    __DIR__ . '/config/global.php',
    __DIR__ . '/config/local.php',
    fn() => ['cache' => ['enabled' => true]],
]);

$config = $aggregator->load();

echo $config->get('cache.enabled'); // true

ConfigProviderInterface example

namespace App\Domain\Module;

use MarekBaron\Config\ConfigProviderInterface;

class ConfigProvider implements ConfigProviderInterface
{
    public function __invoke(): array
    {
        return [
            'factories' => [
                UserLoginHandler::class => UserLoginHandlerFactory::class,
            ],
            'routes' => [
                // your routes
            ],
            // anything else
        ];
    }
}

Development (optional)

A Dockerfile and docker-compose.yml are included for local development. They are excluded from Packagist via .gitattributes.

docker compose run --rm dev composer check

License

MIT License © Marek Baron

PHPUnit Packagist License

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2025-10-22