承接 ucarsolutions/recipient-resolver 相关项目开发

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

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

ucarsolutions/recipient-resolver

最新稳定版本:0.0.6

Composer 安装命令:

composer require ucarsolutions/recipient-resolver

包简介

simple leightweight key and environment based recipient resolver service

README 文档

README

Small, zero-magic library to resolve named recipient lists (e.g. alerts, billing) into a structured Recipient object with To / CC / BCC. Simple YAML config in, objects out. Works great in PHP apps and can be wrapped for CLI/other languages.

Why?

  • Centralize who gets which emails (alerts, ops, marketing, …)
  • Keep config in version control (YAML)
  • Resolve lists reliably in code (alertsRecipient(to: ["alerts@example.com"]))

Features

  • ✅ Tiny API: all() and resolve($list)
  • ✅ YAML provider included
  • Recipient value object (TO/CC/BCC) + NullRecipient fallback
  • ✅ JSON-serializable recipients
  • ✅ Framework-agnostic, strict types
  • 🔌 Extensible via RecipientProviderInterface

Install

composer require ucarsolutions/recipient-resolver

Usage

1) YAML config (with TO/CC/BCC)

# recipients.yaml
alerts:
  receiver:
    - alerts@example.com
  cc:
    - cc.alerts@example.com
  bcc: []

billing:
  receiver:
    - billing@example.com
    - finance@example.com
  cc: []
  bcc:
    - billing.bcc@example.com

marketing-de:
  receiver:
    - de.marketing@example.com

Schema: Each top-level key is a list name. Under it, use arrays receiver, cc, and bcc. Missing keys are treated as empty lists. Invalid emails are skipped.

2) PHP

<?php
use Ucarsolutions\RecipientResolver\Provider\YamlRecipientProvider;
use Ucarsolutions\RecipientResolver\Service\RecipientResolver;
use Ucarsolutions\RecipientResolver\Entity\Recipient;
use Ucarsolutions\RecipientResolver\Entity\NullRecipient;

$provider = new YamlRecipientProvider(__DIR__ . '/recipients.yaml');
$resolver = new RecipientResolver($provider);

// Get the whole map
/** @var array<string, Recipient> $all */
$all = $resolver->all();

// Resolve a single list
$alerts = $resolver->resolve('alerts'); // Recipient

$to  = $alerts->getReceiver();        // ['alerts@example.com']
$cc  = $alerts->getCarbonCopy();      // ['cc.alerts@example.com']
$bcc = $alerts->getBlindCarbonCopy(); // []

// Unknown list → NullRecipient (safe no-op)
$unknown = $resolver->resolve('does-not-exist'); // NullRecipient
$unknown->getReceiver(); // []

// JSON (e.g., for logging)
$json = json_encode($alerts, JSON_THROW_ON_ERROR);
// {"recipient":["alerts@example.com"],"carbonCopy":["cc.alerts@example.com"],"blindCarbonCopy":[]}

Extensibility

Implement your own source by plugging into the interface:

<?php
use Ucarsolutions\RecipientResolver\Entity\Recipient;
use Ucarsolutions\RecipientResolver\Provider\RecipientProviderInterface;

/**
 * @return array<string, Recipient>
 */
final class MyDbRecipientProvider implements RecipientProviderInterface
{
    public function provide(): array
    {
        // Build Recipient objects from your data source
        return [
            'alerts' => new Recipient(
                receiver: ['a@example.com'],
                carbonCopy: [],
                blindCarbonCopy: [],
            ),
        ];
    }
}

Then wire it:

<?php
use Ucarsolutions\RecipientResolver\Service\RecipientResolver;

$resolver = new RecipientResolver(new MyDbRecipientProvider());

Behavior & Guarantees

  • Validation: Emails are validated with filter_var(..., FILTER_VALIDATE_EMAIL). Invalid entries are skipped.
  • Empties: Missing sections (receiver/cc/bcc) → treated as empty arrays.
  • Duplicates: Preserved (provider does not deduplicate).
  • Unknown lists: resolve() returns NullRecipient (all arrays empty).

Testing

This repo ships with PHPUnit tests using real files/classes (no mocks).

composer install
vendor/bin/phpunit

Roadmap help welcome!

  • Optional de-duplication per list
  • Optional “merge providers” (e.g., base YAML + env override)
  • Optional CLI wrapper to print JSON/CSV/lines

Contributing

Issues and PRs are very welcome. Keep it small, readable, and covered by tests.
For new providers, add minimal docs + tests.

License

MIT © Ucar Solutions

ucarsolutions/recipient-resolver 适用场景与选型建议

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

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

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

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-11-08