承接 sirix/sirix-config 相关项目开发

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

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

sirix/sirix-config

Composer 安装命令:

composer require sirix/sirix-config

包简介

Utils to load, parse and work with configuration on Mezzio projects

README 文档

README

Latest Stable Version Total Downloads Latest Unstable Version License PHP Version Require

Utils to load, parse and work with configuration on Mezzio projects.

This library is based on the shlinkio/shlink-config project, with some modifications and extensions for our specific requirements.

Installation

composer install sirix/sirix-config

This library is also a mezzio module which provides its own ConfigProvider. Add it to your configuration to get everything automatically set up.

Included utils

Global functions

All functions are available globally (no use function needed):

  • env(string $key, mixed $default = null, ?string $type = null): mixed — Read an environment variable with optional type casting.
  • parseEnvVar(string $value): string|int|bool|null — Parse a raw env value (handles true, false, null, empty, numeric).
  • castEnvValue(string $value, string $type): mixed — Cast a raw env string to the specified type.
  • formatEnvVarValue(mixed $value): string — Format a value for use as an env var string.
  • formatEnvVarValueOrNull(mixed $value): string|null — Same as above, returns null for non-scalar/non-array values.
  • loadConfigFromGlob(string $globPattern): array — Load and merge all PHP config files matching a glob pattern.
  • loadEnvVarsFromConfig(string $configPath, ?array $allowedEnvVars = null): void — Load config and set env vars from it.
  • putNotYetDefinedEnv(string $key, mixed $value): void — Set an env var only if it is not already defined.

env() function

// Without type (auto-detect: bool, int, string, null)
env('DEBUG');              // true
env('PORT');               // 8080
env('NAME', 'default');    // 'default' if NAME is not set

// With explicit type casting
env('PORT', '8080', 'int');       // (int) 8080
env('RATE', '3.14', 'float');     // (float) 3.14
env('NAME', 'foo', 'string');     // 'foo'
env('DEBUG', 'true', 'bool');     // true
env('HOSTS', 'a,b,c', 'array');   // ['a', 'b', 'c']

Supported types: int/integer, float/double, string, bool/boolean, array (comma-separated).

Config providers and factories

  • EnvVarLoaderProvider: A config provider which loads the entries of the loaded config into env vars and always returns empty. Designed to be the first config provider in the pipeline.

  • DottedAccessConfigAbstractFactory: An abstract factory that lets any config param to be fetched as a service by using the config.foo.bar notation.

  • ValinorConfigFactory: A PSR-11 factory that lets you map arbitrary objects from arrays, using cuyz/valinor.

    In order to use it, you have to register the object to map as a service, and the ValinorConfigFactory with static access using the service that returns the raw array with the data as the static method name:

    <?php
    
    declare(strict_types=1);
    
    return [
        MyCoolOptions::class => [ValinorConfigFactory::class, 'config.foo.options'],
    ];

    It is useful to combine this factory with the DottedAccessConfigAbstractFactory.

Valinor cache configuration

ValinorConfigFactory supports an optional filesystem cache, configurable under the sirix_config.valinor key in your application config. Options:

  • cache (bool): Enable/disable Valinor mapping cache. Default: false.
  • cache_directory (string): Directory where cache files are stored. Default: data/cache/valinor.
  • development_mode (bool): When true, enables file-watching cache to auto‑invalidate entries when source files change. Default: false.

Example config:

<?php

declare(strict_types=1);

return [
    'sirix_config' => [
        'valinor' => [
            'cache' => true,
            'cache_directory' => 'data/cache/valinor',
            'development_mode' => true,
        ],
    ],
];

sirix/sirix-config 适用场景与选型建议

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

它主要适用于以下技术方向: 「configuration」 「config」 「environment」 「env」 「laminas」 「mezzio」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-02-15