承接 compono-kit/money-formatters 相关项目开发

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

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

compono-kit/money-formatters

Composer 安装命令:

composer require compono-kit/money-formatters

包简介

Money formatter classes for implementations of compono-kit/money-interfaces

README 文档

README

A lightweight PHP package providing flexible and locale-aware money string formatters.
It includes three formatter classes for different use cases — from simple decimal formatting to fully localized currency output. Uses interfaces from compono-kit/money-interfaces.

Requirements

  • PHP >= 8.3
  • compono-kit/money-interfaces

📦 Installation

composer require compono-kit/money-formatters

🚀 Overview

This package defines three money formatters that implement the same interface FormatsMoneyString.

Class Description Locale-Aware Controls Currency Symbol
SimpleMoneyFormatter Simple decimal formatting without localization (technical format).
LocalizedDecimalMoneyFormatter Locale-based decimal formatting using PHP’s Intl component, with manual control over the currency symbol position.
LocalizedMoneyFormatter Fully localized currency formatting using Intl’s built-in currency rules. ❌ (handled by locale)

Interfaces & Traits

Each formatter implements:

interface FormatsMoneyString
{
    public function formatString(RepresentsMoney $money): string;
}

Classes

SimpleMoneyFormatter

Formats a RepresentsMoney instance as a plain decimal string without localization.
Useful for APIs or technical output where consistency matters more than human readability.

$formatter = new SimpleMoneyFormatter(CurrencyOutput::RIGHT_SYMBOL);

echo $formatter->formatString($money);
// Example: 1234.56 €

Features

  • No locale dependency.
  • No thousand separators.
  • Optional control for currency presentation using enum CurrencyOutput:
    • LEFT_SYMBOL => Example: € 1234.56
    • RIGHT_SYMBOL => Example: 1234.56 €
    • LEFT_ISO_CODE => Example: EUR 1234.56
    • RIGHT_ISO_CODE => Example: 1234.56 EUR
    • NONE => Example: 1234.56

LocalizedDecimalMoneyFormatter

Formats a money value using PHP’s \NumberFormatter with the DECIMAL style.
This provides localized decimal separators, but keeps currency presentation customizable.

$formatter = new LocalizedDecimalMoneyFormatter('de_DE', CurrencyOutput::LEFT_SYMBOL);

echo $formatter->formatString($money);
// Example (German locale, left symbol): € 1.234,56

Features

  • Locale-dependent decimal separators.
  • Ideal when you want localized numbers but still want control over currency display.
  • Optional control for currency presentation using enum CurrencyOutput:
    • LEFT_SYMBOL => Example: € 1.234,56
    • RIGHT_SYMBOL => Example: 1.234,56 €
    • LEFT_ISO_CODE => Example: EUR 1.234,56
    • RIGHT_ISO_CODE => Example: 1.234,56 EUR
    • NONE => Example: 1.234,56

LocalizedMoneyFormatter

Uses PHP’s \NumberFormatter::CURRENCY to produce fully localized money strings.
This is the most “natural” presentation for end users.

$formatter = new LocalizedMoneyFormatter('en_US');

echo $formatter->formatString($money);
// Example: $1,234.56

Features

  • Fully localized formatting.
  • Locale determines symbol, placement, and spacing automatically.
  • Best suited for UI display and end-user presentation.

⚙️ CurrencyOutput Options

CurrencyOutput defines how the currency symbol is positioned:

CurrencyOutput::LEFT_SYMBOL // e.g. € 1.234,56
CurrencyOutput::RIGHT_SYMBOL // e.g. 1.234,56 €
CurrencyOutput::LEFT_ISO_CODE  // e.g. EUR 1.234,56
CurrencyOutput::RIGHT_ISO_CODE   // e.g.  1.234,56 EUR
CurrencyOutput::NONE   // e.g. 1.234,56

🢙 Summary

This package is designed to be small, predictable, and composable
you decide how much localization you want, while keeping all formatters interchangeable via the same interface

compono-kit/money-formatters 适用场景与选型建议

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

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

围绕 compono-kit/money-formatters 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: proprietary
  • 更新时间: 2025-10-18