PHPackages                             nilz/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. nilz/money

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

nilz/money
==========

Implementation of money class

1.10(2y ago)114.6k↓50%MITPHPPHP &gt;=7.4

Since Dec 5Pushed 2y ago2 watchersCompare

[ Source](https://github.com/Nilz11/money)[ Packagist](https://packagist.org/packages/nilz/money)[ RSS](/packages/nilz-money/feed)WikiDiscussions master Synced 1mo ago

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

[![](https://camo.githubusercontent.com/355edf597a846eee03074094f73481322856008728787c37e5ea407ecf9f6d66/68747470733a2f2f7472617669732d63692e6f72672f4e696c7a31312f6d6f6e65792e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/Nilz11/money)

A real world implementation of an extendable Money object using integers of smallest currency unit as calculation.

This library was created because other existing solutions had one or more of the following drawbacks:

- missing extendability of Money class
- dependency on fixed currency class
- missing methods like format and convertTo currency
- errors in implementation that caused to have rounding errors and missing cents in e.g. summing up prices
- library not being maintained anymore

Free to use. Use it or leave it.

#### Examples

[](#examples)

Create a money object:

```
use Nilz\Money\Money;
use Nilz\Money\Currency\ISO4217Currency;

$money = new Money(420, new ISO4217Currency('EUR'));

$money = Money::fromDefaultUnitAmount('4.20', 'EUR');
```

---

Get amount of money object:

```
//420
echo $money->getAmount();

//4.20
echo $money->getDefaultUnitAmount();

//4,20 €
echo $money->getFormattedAmount('de_DE');
```

---

Sum up two money objects:

```
$a = Money::fromDefaultUnitAmount('4.20', 'EUR');
$b = Money::fromDefaultUnitAmount('2.10', 'EUR');

$c = $a->add($b);

//6.30
echo $c->getAmount();

//4.20
echo $a->getAmount();

//2.10
echo $b->getAmount();
```

Other arithmetic examples:

```
$a = Money::fromDefaultUnitAmount('4.20', 'EUR');
$b = Money::fromDefaultUnitAmount('2.10', 'EUR');

$a->subtract($b);

$a->multiply(1.2);
$a->divide(1.2);
```

If you need other methods to perform calculations, you can easily extend the money object or put a pull request to extend it.

---

Use custom currency:

```
use Nilz\Money\Currency\Currency;

//alpha3 code, factor for smallest unit representation, decimal digits to round two
$money = new Money(420, new Currency('EUR', 100, 2));
```

You can also implement a custom currency object by implementing the CurrencyInterface.

###  Health Score

35

—

LowBetter than 80% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity25

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity70

Established project with proven stability

 Bus Factor1

Top contributor holds 75% 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 ~261 days

Recently: every ~5 days

Total

12

Last Release

941d ago

PHP version history (2 changes)1.0.0PHP &gt;=5.6

1.5PHP &gt;=7.4

### Community

Maintainers

![](https://www.gravatar.com/avatar/f0672ada1350bf5f6751c8f77dfeccf356300888c08f602b6e13d87ac32c4dd4?d=identicon)[Nilz11](/maintainers/Nilz11)

---

Top Contributors

[![Nilz11](https://avatars.githubusercontent.com/u/1756403?v=4)](https://github.com/Nilz11 "Nilz11 (15 commits)")[![bouzidilyasse](https://avatars.githubusercontent.com/u/94681128?v=4)](https://github.com/bouzidilyasse "bouzidilyasse (5 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[fatturaelettronicaphp/fattura-elettronica

Pacchetto PHP per la lettura, la generazione e la validazione della fattura elettronica, sia per la Pubblica Amministrazione che tra privati (B2B)

4951.7k](/packages/fatturaelettronicaphp-fattura-elettronica)

PHPackages © 2026

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