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

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

evp/money
=========

Money library

2.10.0(1y ago)962.2k↓40.5%11[2 issues](https://github.com/paysera/lib-money/issues)3MITPHPPHP ^7.0 || ^8.0CI passing

Since May 7Pushed 1y ago7 watchersCompare

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

READMEChangelog (10)Dependencies (7)Versions (17)Used By (3)

PHP Library for Operations with Money
=====================================

[](#php-library-for-operations-with-money)

[![Build Status](https://github.com/paysera/lib-money/workflows/CI/badge.svg)](https://github.com/paysera/lib-money/actions)[![Latest Stable Version](https://camo.githubusercontent.com/c07d88079e2543bd3ebbc16a217fff3294e288effcd76ec9cc44d948aa5d0f31/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6576702f6d6f6e65792e737667)](https://packagist.org/packages/evp/money)[![Total Downloads](https://camo.githubusercontent.com/68e144ef1110304cc99e78f4579a88838835e0be606e568c488bad6aa5451b77/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6576702f6d6f6e65792e737667)](https://packagist.org/packages/evp/money)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![PHP Version Require](https://camo.githubusercontent.com/0262dce7cf44c72b60fcbf6aa87bfd2e43cc6bc615a1669a4a4bdd47c6dd8ab3/687474703a2f2f706f7365722e707567782e6f72672f6576702f6d6f6e65792f726571756972652f706870)](https://packagist.org/packages/evp/money)

Instead of storing prices, profit and any other amount of money in float or integer variable, use Money value object instead. It groups amount with currency, as amount without currency does not give much information.

Installing
----------

[](#installing)

```
composer require evp/money
```

### Why not floats?

[](#why-not-floats)

- Floats are not reliable for making operations with money as they can loose precision and cents can get lost.

### Why not integers?

[](#why-not-integers)

- When max integer value is reached, crazy things can happen: it can be truncated or even get negative. These types of errors can be critical, especially when working with money. On 32bit systems (and any system on Windows) max int value is 2147483647. As this is enough for most cases, some currencies are relatively very small compared to others (for example, 2,147,483,647.00 BYR is about 150,000.00 EUR).
- There might be cases, where money should be calculated or even saved without rounding to smallest available units. For example, very small commissions (parts of cent), which can add to a big amount when large number of them are added.
- When storing amount as integer, you must always take into account the currency divisor (smallest available unit in that currency) before outputting the result or any other operation. For example, most currencies have cents as their smallest unit while smallest unit for Bahraini Dinar is 0.001 and Japanese Yen has no cents at all. Alternatively, if you always store units as cents, you cannot represent smallest units of some currencies.

### Architecture

[](#architecture)

`Money` is value object - it's immutable. In other words, if you need to change the amount or currency, just create another `Money` object. The same `Money` object can be referenced in several places, so changing only the fields of this object could unintentionally change money amount or currency in some other place.

Api
---

[](#api)

`Money` class provides self-contained logic for arithmetic and comparison operations with other `Money` instances. All arithmetic operations returns new `Money` instance.

- `Money::add` - adds current Money amount to given; throws exception if currencies are different.
- `Money::sub` - subtracts given Money amount from current Money amount; throws exception if currencies are different.
- `Money::mul` - multiplies current money amount by given multiplier.
- `Money::div` - divides current money amount by given divisor.
- `Money::negate` - negates current money amount.
- `Money::round` - rounds current money amount to given number of decimal places; if no precision is given, rounds to maximum precision for current currency.
- `Money::ceil` - rounds current money amount to ceil; if no precision is given, rounds to maximum precision for current currency.
- `Money::floor` - rounds current money amount to floor; if no precision is given, rounds to maximum precision for current currency.
- `Money::check` - checks if current amount is not too small; throws exception if so.
- `Money::isGt` - tells if current money is greater than given.
- `Money::isGte` - tells if current money is greater or equal than given.
- `Money::isLt` - tells if current money is less than given.
- `Money::isLte` - tells if current money is less or equal than given.
- `Money::isEqual` - tells if current money is equal to given.
- `Money::isNegative` - tells if current money is negative.
- `Money::isPositive` - tells if current money is positive.
- `Money::isZero` - tells if current money has zero amount.
- `Money::isSameCurrency` - tells if current money has same currency as given.
- `Money::abs` - returns money with absolute amount.
- `Money::getArrayRepresentation` - returns array with keys `amount` and `currency`.
- `Money::getAsString` - returns string with concatenated `amount` and `currency` separated by space.
- `Money::getFraction` - returns number of decimal places supported by given currency.

Usage
-----

[](#usage)

```
$money = new Money(1, 'EUR');
$timesTwo = $money->mul(2);

$money->isLt($timesTwo); // true
```

###  Health Score

49

—

FairBetter than 95% of packages

Maintenance43

Moderate activity, may be stable

Popularity38

Limited adoption so far

Community27

Small or concentrated contributor base

Maturity76

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~169 days

Recently: every ~329 days

Total

16

Last Release

391d ago

Major Versions

1.6.2 → 2.0.02018-10-22

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

2.8.0PHP ^7.0 || ^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/9d385187c2b529d5c1189dfc3763972f76738d24293593ff3db876fff82321db?d=identicon)[paysera.com](/maintainers/paysera.com)

---

Top Contributors

[![borilyordanov](https://avatars.githubusercontent.com/u/11679283?v=4)](https://github.com/borilyordanov "borilyordanov (10 commits)")[![a-malinovskis](https://avatars.githubusercontent.com/u/68857442?v=4)](https://github.com/a-malinovskis "a-malinovskis (3 commits)")[![ivelinahristova](https://avatars.githubusercontent.com/u/3619021?v=4)](https://github.com/ivelinahristova "ivelinahristova (2 commits)")[![tomas7777](https://avatars.githubusercontent.com/u/9091359?v=4)](https://github.com/tomas7777 "tomas7777 (2 commits)")[![pelanis](https://avatars.githubusercontent.com/u/31431703?v=4)](https://github.com/pelanis "pelanis (1 commits)")[![vaskevicius](https://avatars.githubusercontent.com/u/22121652?v=4)](https://github.com/vaskevicius "vaskevicius (1 commits)")[![vbartusevicius](https://avatars.githubusercontent.com/u/7325630?v=4)](https://github.com/vbartusevicius "vbartusevicius (1 commits)")[![vytautasgimbutas](https://avatars.githubusercontent.com/u/1172971?v=4)](https://github.com/vytautasgimbutas "vytautasgimbutas (1 commits)")[![zakharshokel](https://avatars.githubusercontent.com/u/218759518?v=4)](https://github.com/zakharshokel "zakharshokel (1 commits)")[![dgeorgievadaskalova](https://avatars.githubusercontent.com/u/206524907?v=4)](https://github.com/dgeorgievadaskalova "dgeorgievadaskalova (1 commits)")[![dzmitrybitsiutski](https://avatars.githubusercontent.com/u/158209542?v=4)](https://github.com/dzmitrybitsiutski "dzmitrybitsiutski (1 commits)")[![mSprunskas](https://avatars.githubusercontent.com/u/4427922?v=4)](https://github.com/mSprunskas "mSprunskas (1 commits)")

---

Tags

moneymoney-library

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[shyim/danger-php

Port of danger to PHP

8544.9k](/packages/shyim-danger-php)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[symfony/ux-cropperjs

Cropper.js integration for Symfony

19280.3k3](/packages/symfony-ux-cropperjs)[symfony/ux-notify

Native notification integration for Symfony

1274.7k](/packages/symfony-ux-notify)[numero2/contao-storelocator

Contao Plugin for managing stores (or in common address data) and providing a frontend-search based on geo data

121.5k](/packages/numero2-contao-storelocator)

PHPackages © 2026

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