Download the PHP package compono-kit/money-formatters without Composer
On this page you can find all versions of the php package compono-kit/money-formatters. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download compono-kit/money-formatters
More information about compono-kit/money-formatters
Files in compono-kit/money-formatters
Package money-formatters
Short Description Money formatter classes for implementations of compono-kit/money-interfaces
License proprietary
Homepage https://github.com/compono-kit/money-formatters
Informations about the package money-formatters
Money Formatters
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
🚀 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:
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.
Features
- No locale dependency.
- No thousand separators.
- Optional control for currency presentation using enum
CurrencyOutput:LEFT_SYMBOL=> Example: € 1234.56RIGHT_SYMBOL=> Example: 1234.56 €LEFT_ISO_CODE=> Example: EUR 1234.56RIGHT_ISO_CODE=> Example: 1234.56 EURNONE=> 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.
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,56RIGHT_SYMBOL=> Example: 1.234,56 €LEFT_ISO_CODE=> Example: EUR 1.234,56RIGHT_ISO_CODE=> Example: 1.234,56 EURNONE=> 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.
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:
🢙 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