承接 snapshotpl/zf-snap-var-config 相关项目开发

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

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

snapshotpl/zf-snap-var-config

最新稳定版本:4.1.0

Composer 安装命令:

composer require snapshotpl/zf-snap-var-config

包简介

Variables in array

README 文档

README

Variables in array.

Additional provides module for Laminas for configurations.

Usage

Sometimes you want to use same values in other places in your config. What are you doing?

<?php $myIp = '127.0.0.1'; return [ 'db' => $myIp, 'memcache' => $myIp, ];

Of course it's working, but when you want to share $myIp between separate config files thats challange! ZfSnapVarConfig make a magic here!

$data = [ 'ips' => [ 'local' => '127.0.0.1', 'memcache' => '127.0.0.2', 'smtp' => '127.0.0.3' ], 'email' => new ZfSnapVarConfig\Value\Env('ADMIN_EMAIL'), 'db' => ZfSnapVarConfig\Value\Path::fromString('ips/local'), 'memcache' => ZfSnapVarConfig\Value\Path::fromString('ips|memcache', '|'), 'email' => [ 'smtp' => ZfSnapVarConfig\Value\Path::fromArray(['ips', 'smtp']), 'default-mail' => ZfSnapVarConfig\Value\Path::fromString('email'), 'reply-to' => ZfSnapVarConfig\Value\Path::fromString('email'), 'other-address' => new ZfSnapVarConfig\Value\Path('ips', 'smtp'), ], ]; $service = new ZfSnapVarConfig\VarConfigService(); $replaced = $service->replace($data); // or $service($data); assertSame([ 'ips' => [ 'local' => '127.0.0.1', 'memcache' => '127.0.0.2', 'smtp' => '127.0.0.3' ], 'email' => 'your@email.com', 'db' => '127.0.0.1', 'memcache' => '127.0.0.2', 'email' => [ 'smtp' => '127.0.0.3', 'default-mail' => 'your@email.com', 'reply-to' => 'your@email.com', 'other-address' => '127.0.0.3', ], ], $replaced);

On this moment you can use selectors:

  • ZfSnapVarConfig\Value\Path
  • ZfSnapVarConfig\Value\Env
  • ZfSnapVarConfig\Value\Callback

You can write your own value manipulator. Just implement ZfSnapVarConfig\Value and create instance in your config.

How to install?

Via composer.json

composer require snapshotpl/zf-snap-var-config

If you want to use this library as Laminas module add ZfSnapVarConfig to your application.config.php file.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: Unknown
  • 更新时间: 2026-01-04

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固