kaiseki/wp-config 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

kaiseki/wp-config

Composer 安装命令:

composer require kaiseki/wp-config

包简介

Type-safe access to array configurations

README 文档

README

Type-safe access to array configurations.

Wrap a config array (or pull one from a PSR-11 container) and read values with typed accessors that throw on a missing key or a wrong type — so a typo or a misconfigured value fails loudly instead of silently returning null.

Installation

composer require kaiseki/wp-config

Requires PHP 8.2 or newer.

Usage

use Kaiseki\WordPress\Config\NestedArrayConfig;

$config = new NestedArrayConfig([
    'db' => [
        'host' => 'localhost',
        'port' => 3306,
    ],
]);

$config->string('db/host'); // "localhost"
$config->int('db/port');    // 3306
$config->has('db/user');    // false

Paths are slash-separated. The typed getters (string(), int(), float(), bool(), array()) throw UnknownKeyException if the path is missing and InvalidValueException if the value is not of the expected type. has() reports whether a path resolves.

From a PSR-11 container

Config::get() resolves the ConfigInterface service from a container:

use Kaiseki\WordPress\Config\Config;

$config = Config::get($container); // expects ConfigInterface::class in the container

ConfigProvider wires that up for laminas-style config aggregators: it aliases ConfigInterface to NestedArrayConfig and registers a factory that builds the config from the container's config entry.

Config::initClassMap() resolves a map of keys to class instances from the container:

$map = Config::initClassMap($container, ['logger' => LoggerInterface::class]);
// ['logger' => <instance from container>]

Development

composer install
composer check   # check-deps, cs-check, phpstan, phpunit

License

MIT — see LICENSE.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2022-02-05

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固