定制 comphp/config-yaml 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

comphp/config-yaml

Composer 安装命令:

composer require comphp/config-yaml

包简介

Configuration Driver for CommonPHP which encodes/decodes the YAML

README 文档

README

Configuration driver for CommonPHP that encodes and decodes YAML configuration data.

Requirements

  • PHP ^8.5
  • comphp/config:^0.3
  • symfony/yaml:^8.0

Installation

Once this package is available through your Composer repositories, install it with:

composer require comphp/config-yaml

Usage

<?php

use CommonPHP\Drivers\Config\YAML\YamlConfigurationDriver;

$driver = new YamlConfigurationDriver();

$config = [
    'app' => 'demo',
    'debug' => true,
    'database' => [
        'host' => 'localhost',
    ],
];

$yaml = $driver->encode($config);
$decoded = $driver->decode($yaml);

$driver->write(__DIR__ . '/config.yaml', $config);
$fromFile = $driver->read(__DIR__ . '/config.yaml');

Format Notes

This driver uses Symfony YAML. YAML mappings decode to arrays, empty YAML decodes to an empty array, and scalar-only YAML is rejected as configuration data.

Error Handling

Read, write, parse, validation, and unsupported value failures throw CommonPHP config exceptions such as ConfigReadException, ConfigWriteException, ConfigValidationException, or ConfigException.

Documentation

License

MIT. See LICENSE.md.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-05-20