PHPackages                             ez-php/money - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. ez-php/money

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

ez-php/money
============

Immutable Money and Currency value objects for the ez-php ecosystem — ISO 4217 currencies, arbitrary-precision arithmetic via ez-php/bignum, allocation, and locale-aware formatting

1.11.0(4w ago)00MITPHPPHP ^8.5CI passing

Since Apr 17Pushed 4w agoCompare

[ Source](https://github.com/ez-php/money)[ Packagist](https://packagist.org/packages/ez-php/money)[ Docs](https://github.com/ez-php/money)[ RSS](/packages/ez-php-money/feed)WikiDiscussions main Synced 1w ago

READMEChangelogDependencies (7)Versions (13)Used By (0)

ez-php/money
============

[](#ez-phpmoney)

Immutable `Money` and `Currency` value objects for the ez-php ecosystem.

- ISO 4217 currencies with minor-unit scale (bundled, no network calls)
- Arbitrary-precision arithmetic via `ez-php/bignum`
- Allocation without losing a minor unit
- Locale-aware formatting via PHP's `ext-intl`

Requirements
------------

[](#requirements)

- PHP 8.5+
- `ext-gmp` (required, via `ez-php/bignum`)
- `ext-intl` (optional, for `IntlMoneyFormatter` / `IntlMoneyParser`)

Installation
------------

[](#installation)

```
composer require ez-php/money
```

Usage
-----

[](#usage)

### Creating Money

[](#creating-money)

```
use EzPhp\Money\Money;

$price  = Money::of('19.99', 'EUR');          // from decimal string
$tax    = Money::ofMinorUnits(199, 'EUR');     // from cents → 1.99 EUR
$zero   = Money::zero('USD');

// JPY has no minor units (scale = 0)
$yen    = Money::of('1000', 'JPY');
```

### Arithmetic

[](#arithmetic)

```
use EzPhp\BigNum\RoundingMode;

$total  = $price->add($tax);                  // 21.98 EUR
$half   = $price->divide(2, RoundingMode::HALF_UP);
$vat    = $price->multiply('0.19');           // 3.80 EUR (rounded HALF_UP)
```

### Allocation

[](#allocation)

```
// Split 10.00 EUR three ways — no cent is lost
[$a, $b, $c] = Money::of('10.00', 'EUR')->allocate([1, 1, 1]);
// 3.34 EUR, 3.33 EUR, 3.33 EUR  (total = 10.00 EUR ✓)

// Weighted split
[$deposit, $remainder] = Money::of('100.00', 'EUR')->allocate([1, 3]);
// 25.00 EUR, 75.00 EUR
```

### Comparison

[](#comparison)

```
$price->isGreaterThan($tax);   // true
$price->isEqualTo($tax);       // false
$price->compareTo($tax);       // 1
```

### Minor units

[](#minor-units)

```
$price->toMinorUnits()->toString();  // "1999"
```

### Currencies

[](#currencies)

```
use EzPhp\Money\Currency;

$eur = Currency::of('EUR');
$eur->getCode();        // "EUR"
$eur->getNumericCode(); // "978"
$eur->getName();        // "Euro"
$eur->getScale();       // 2
$eur->getSymbol();      // "€"
```

### Formatting

[](#formatting)

```
use EzPhp\Money\Formatter\DecimalMoneyFormatter;
use EzPhp\Money\Formatter\IntlMoneyFormatter;

$plain = new DecimalMoneyFormatter();
$plain->format($price);                        // "19.99"

$withCode = new DecimalMoneyFormatter(includeCurrencyCode: true);
$withCode->format($price);                     // "19.99 EUR"

$intl = new IntlMoneyFormatter('de_DE');        // requires ext-intl
$intl->format($price);                         // "19,99 €"
```

### Parsing

[](#parsing)

```
use EzPhp\Money\Parser\DecimalMoneyParser;
use EzPhp\Money\Parser\IntlMoneyParser;

$parser = new DecimalMoneyParser();
$money  = $parser->parse('19.99', 'EUR');

$intlParser = new IntlMoneyParser('en_US');     // requires ext-intl
$money      = $intlParser->parse('$19.99', 'USD');
```

### Exception hierarchy

[](#exception-hierarchy)

```
MoneyException (extends RuntimeException)
├── CurrencyMismatchException  — arithmetic between different currencies
└── UnknownCurrencyException   — unrecognised ISO 4217 code

```

Currencies
----------

[](#currencies-1)

The bundled registry covers ~150 ISO 4217 currencies. Lookups are case-insensitive and cached after first access.

```
use EzPhp\Money\CurrencyRegistry;

CurrencyRegistry::has('EUR');    // true
CurrencyRegistry::has('ZZZ');   // false
CurrencyRegistry::all();         // array
```

###  Health Score

42

—

FairBetter than 88% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~2 days

Total

12

Last Release

29d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/122030400?v=4)[AU9500](/maintainers/AU9500)[@AU9500](https://github.com/AU9500)

---

Top Contributors

[![AU9500](https://avatars.githubusercontent.com/u/122030400?v=4)](https://github.com/AU9500 "AU9500 (28 commits)")

---

Tags

phpmoneycurrencybigdecimalfinancialiso4217ez-php

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StylePHP CS Fixer

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ez-php-money/health.svg)

```
[![Health](https://phpackages.com/badges/ez-php-money/health.svg)](https://phpackages.com/packages/ez-php-money)
```

###  Alternatives

[grumpydictator/firefly-iii

Firefly III: a personal finances manager.

23.6k69.4k](/packages/grumpydictator-firefly-iii)[firefly-iii/data-importer

Firefly III Data Import Tool.

7905.8k](/packages/firefly-iii-data-importer)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
