定制 phpnomad/json-config-integration 二次开发

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

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

phpnomad/json-config-integration

Composer 安装命令:

composer require phpnomad/json-config-integration

包简介

description

README 文档

README

Latest Version Total Downloads PHP Version License

phpnomad/json-config-integration wires JSON-file-backed configuration into a PHPNomad application. It binds the strategies from phpnomad/array-json-config to the interfaces defined in phpnomad/config, then registers a set of JSON files against ConfigService during the loader bootstrap. Install this package when you want configuration values stored in JSON files on disk and accessible anywhere via dot-notation keys.

Installation

composer require phpnomad/json-config-integration

What This Provides

  • A single ConfigInitializer class that binds ArrayConfigStrategy to ConfigStrategy and JsonFileLoader to ConfigFileLoaderStrategy in the DI container.
  • During load(), it walks the constructor-supplied ['namespace' => '/path/to/file.json'] map and calls ConfigService::registerConfig() for each entry, so every file is parsed and indexed in one pass.
  • Implementations of HasClassDefinitions, Loadable, and CanSetContainer, so the initializer drops into any phpnomad/loader bootstrap sequence without extra glue.

Requirements

  • phpnomad/config
  • phpnomad/array-json-config
  • phpnomad/di ^2.0
  • phpnomad/loader ^1.0 || ^2.0

Usage

Register the initializer with your application's bootstrapper and hand it a map of namespace keys to JSON file paths.

<?php

use PHPNomad\Component\JsonConfigIntegration\ConfigInitializer;
use PHPNomad\Config\Services\ConfigService;
use PHPNomad\Loader\Bootstrapper;

$configInitializer = new ConfigInitializer([
    'app'      => __DIR__ . '/config/app.json',
    'database' => __DIR__ . '/config/database.json',
    'mailer'   => __DIR__ . '/config/mailer.json',
]);

$bootstrapper = new Bootstrapper($container, $configInitializer);
$bootstrapper->load();

/** @var ConfigService $config */
$config = $container->get(ConfigService::class);

$config->get('app.debug');             // value from app.json
$config->get('database.default.host'); // nested lookup into database.json
$config->get('mailer.port', 587);      // default fallback

Each file is parsed once during load() and its contents are stored under the namespace key you provided, so consumers read values through ConfigService without re-reading the filesystem.

Documentation

Full documentation for PHPNomad lives at phpnomad.com.

License

MIT. See LICENSE.

phpnomad/json-config-integration 适用场景与选型建议

phpnomad/json-config-integration 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 52 次下载、GitHub Stars 达 0, 最近一次更新时间为 2024 年 12 月 18 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 phpnomad/json-config-integration 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 phpnomad/json-config-integration 我们能提供哪些服务?
定制开发 / 二次开发

基于 phpnomad/json-config-integration 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-12-18