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

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

macmotp/money
=============

Light PHP Library to handle Money and Currencies

v1.0.1(1y ago)11.1k↓50%1MITPHPPHP &gt;=8.2

Since Jul 13Pushed 1y ago2 watchersCompare

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

READMEChangelog (7)Dependencies (4)Versions (16)Used By (0)

Light Money Handler
===================

[](#light-money-handler)

[![Latest Version on Packagist](https://camo.githubusercontent.com/d53892c9bbb529d9414acee03b2a2ec8dca23a755a2c29e7c130068037e8629a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61636d6f74702f6d6f6e65792e737667)](https://packagist.org/packages/macmotp/money)[![Total Downloads](https://camo.githubusercontent.com/bdd5531d485ed52c3751c1354c213c247cc4578795029a23987f989d706d86d5/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d61636d6f74702f6d6f6e65792e737667)](https://packagist.org/packages/macmotp/money)

**Library to Handle Money and Currencies in PHP, simple and light**

Useful for any ecommerce, fintech, or any app that requires 💰.

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

[](#requirements)

- PHP &gt;= 8.2

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

[](#installation)

Install the package via composer:

```
composer require macmotp/money
```

Usage
-----

[](#usage)

### Create Money objects

[](#create-money-objects)

```
use Macmotp\Money;
use Macmotp\Support\CurrencyCode;

// Amounts are always in cents (or lowest minor unit)!
$amount = 100;

// All Currencies adopt ISO 4217 standard
$currency = CurrencyCode::USD;

// Create the object
$money = new Money($amount, $currency);

// Alternative methods
$money = new Money($amount, 'USD');
$money = Money::make($amount, $currency);

echo $money->print();

// (string) '1.00$'

// Another example with Vietnamese Dong
$money = new Money(10000, CurrencyCode::VND);

echo $money->print();

// (string) '10 000₫'
```

#### List of basic methods

[](#list-of-basic-methods)

- `getAmount()`: return the amount in cents;
- `getAmountForHumans()`: return the amount in decimals;
- `getCurrencyCode()`: return the currency code;
- `getCurrencySymbol()`: return the currency symbol;
- `getCurrency()`: return the currency object (as Currency implementation, not as string);
- `clone()`: clone the entire object;
- `zero()`: set the amount to zero;

*If you want to print any of the currency properties, check the Format class.**For example: if you want to get the currency code, you can run `$money->getCurrencyCode()`*

### Print Money (on the screen, not for real)

[](#print-money-on-the-screen-not-for-real)

```
use Macmotp\Money;
use Macmotp\Support\CurrencyCode;

$money = new Money(12345, CurrencyCode::USD);

// Default format based on each currency

echo $money->print();

// (string) '123.45$'

// Override the default

echo $money->withCode()
           ->withSpace()
           ->withoutDecimals()
           ->print();

// (string) '123 USD'
```

#### List of methods for printing

[](#list-of-methods-for-printing)

- `toArray()`: convert the object into array;
- `getCurrency()->toArray()`: convert the currency object into array;
- `withSymbol()`: print the symbol and not the currency code;
- `withoutSymbol()`: do not print neither symbol nor currency code;
- `withCode()`: print the currency code and not the code;
- `withoutCode()`: do not print neither symbol nor currency code;
- `withSymbolOnLeft()`: print symbol on the left;
- `withSymbolOnRight()`: print symbol on the right;
- `withCodeOnLeft()`: print currency code on the left;
- `withCodeOnRight()`: print currency code on the right;
- `withSpace()`: print a space between the amount and the currency;
- `withoutSpace()`: do not print a space between the amount and the currency;
- `withoutDecimals()`: do not print decimals of the amount;
- `withDecimalSeparator(string $decimalSeparator)`: override default decimal separator character;
- `withThousandsSeparator(string $thousandsSeparator)`: override default thousands separator character;
- `withNumberOfDecimals(int $numberOfDecimals)`: set the precision of the decimals;

### Calculate with Money

[](#calculate-with-money)

```
use Macmotp\Money;
use Macmotp\Support\CurrencyCode;

$moneyOne = new Money(200, CurrencyCode::USD);
$moneyTwo = new Money(300, CurrencyCode::USD);

echo $moneyOne->add($moneyTwo);

// new Money(500, CurrencyCode::USD)
```

#### List of calculation methods

[](#list-of-calculation-methods)

- `add(Money $money)`;
- `subtract(Money $money)`;
- `multiply(float $factor, string $flat = '')`;
- `divide(float $factor, string $flat = '')`;
- `inPercentage(float $percentage, string $flat = '')`;
- `absolute()`;

### Aggregate Money

[](#aggregate-money)

```
use Macmotp\Money;
use Macmotp\Support\CurrencyCode;

$moneyOne = new Money(200, CurrencyCode::USD);
$moneyTwo = new Money(300, CurrencyCode::USD);
$moneyThree = new Money(400, CurrencyCode::USD);

echo Money::max($moneyOne, $moneyTwo, $moneyThree);

// new Money(400, CurrencyCode::USD)

echo Money::avg($moneyOne, $moneyTwo, $moneyThree);

// new Money(300, CurrencyCode::USD)
```

#### List of aggregation methods

[](#list-of-aggregation-methods)

- `min(Money ...$money)`: return the minimum amount;
- `max(Money ...$money)`: return the maximum amount;
- `avg(Money ...$money)`: return the average amount;
- `sum(Money ...$money)`: return the sum of all amounts;

### Compare Money

[](#compare-money)

```
use Macmotp\Money;
use Macmotp\Support\CurrencyCode;

$moneyOne = new Money(200, CurrencyCode::USD);
$moneyTwo = new Money(300, CurrencyCode::USD);

echo $moneyOne->isLessThan($moneyTwo);

// (bool) true
```

#### List of comparison methods

[](#list-of-comparison-methods)

- `isSameCurrency(Money ...$money)`;
- `isEqualTo(Money $money)`;
- `isGreaterThan(Money $money)`;
- `isGreaterThanOrEqualTo(Money $money)`;
- `isLessThan(Money $money)`;
- `isLessThanOrEqualTo(Money $money)`;
- `isPositive()`;
- `isNegative()`;
- `isZero()`;
- `isZeroOrPositive()`;
- `isZeroOrNegative()`;

### List of Currencies in the package

[](#list-of-currencies-in-the-package)

```
use Macmotp\Money;

$list = Money::getAllCurrencies();
// This will return a Illuminate\Support\Collection
```

These are the implemented currencies:

- `AED`: United Arab Emirates Dirham
- `AFN`: Afghan Afghani
- `ALL`: Albanian Lek
- `AMD`: Armenian Dram
- `ANG`: Netherlands Antillean Guilder
- `AOA`: Angolan Kwanza
- `ARS`: Argentine Peso
- `AUD`: Australian Dollar
- `AWG`: Aruban Florin
- `AZN`: Azerbaijani Manat
- `BAM`: Bosnia and Herzegovina Convertible Mark
- `BBD`: Barbados Dollar
- `BDT`: Bangladeshi Taka
- `BGN`: Bulgarian Lev
- `BHD`: Bahraini Dinar
- `BIF`: Burundian Franc
- `BMD`: Bermudian Dollar
- `BND`: Brunei Dollar
- `BOB`: Bolivian Boliviano
- `BRL`: Brazilian Real
- `BSD`: Bahamian Dollar
- `BTC`: Bitcoin
- `BTN`: Bhutanese Ngultrum
- `BWP`: Botswana Pula
- `BYN`: Belarusian Ruble
- `BZD`: Belize Dollar
- `CAD`: Canadian Dollar
- `CDF`: Congolese Franc
- `CHF`: Swiss Franc
- `CLP`: Chilean Peso
- `CNY`: Chinese Yuan - Renminbi
- `COP`: Colombian Peso
- `CRC`: Costa Rican Colón
- `CUP`: Cuban Peso
- `CVE`: Cape Verdean Escudo
- `CZK`: Czech Koruna
- `DJF`: Djiboutian Franc
- `DKK`: Danish Krone
- `DOP`: Dominican Peso
- `DZD`: Algerian Dinar
- `EGP`: Egyptian Pound
- `ERN`: Eritrean Nakfa
- `ETB`: Ethiopian Birr
- `EUR`: Euro
- `FJD`: Fijian Dollar
- `FKP`: Falkland Islands Pound
- `GBP`: British Pound
- `GEL`: Georgian Lari
- `GHS`: Ghanaian Cedi
- `GIP`: Gibraltar Pound
- `GMD`: Gambian Dalasi
- `GNF`: Guinean Franc
- `GTQ`: Guatemalan Quetzal
- `GYD`: Guyanese Dollar
- `HKD`: Hong Kong Dollar
- `HNL`: Honduran Lempira
- `HTG`: Haitian Gourde
- `HUF`: Hungarian Forint
- `IDR`: Indonesian Rupiah
- `ILS`: Israeli New Shekel
- `INR`: Indian Rupee
- `IQD`: Iraqi Dinar
- `IRR`: Iranian Rial
- `ISK`: Icelandic Króna
- `JMD`: Jamaican Dollar
- `JOD`: Jordanian Dinar
- `JPY`: Japanese Yen
- `KES`: Kenyan Shilling
- `KGS`: Kyrgyz Som
- `KHR`: Cambodian Riel
- `KMF`: Comorian Franc
- `KPW`: North Korean Won
- `KRW`: South Korean Won
- `KWD`: Kuwaiti Dinar
- `KYD`: Cayman Islands Dollar
- `KZT`: Kazakhstani Tenge
- `LAK`: Lao Kip
- `LBP`: Lebanese Pound
- `LKR`: Sri Lankan Rupee
- `LRD`: Liberian Dollar
- `LSL`: Lesotho Loti
- `LYD`: Libyan Dinar
- `MAD`: Moroccan Dirham
- `MDL`: Moldovan Leu
- `MGA`: Malagasy Ariary
- `MKD`: Macedonian Denar
- `MMK`: Burmese Kyat
- `MNT`: Mongolian Tögrög
- `MOP`: Macanese Pataca
- `MRU`: Mauritanian Ouguiya
- `MUR`: Mauritian Rupee
- `MVR`: Maldivian Rufiyaa
- `MWK`: Malawian Kwacha
- `MXN`: Mexican Peso
- `MYR`: Malaysian Ringgit
- `MZN`: Mozambican Metical
- `NAD`: Namibian Dollar
- `NGN`: Nigerian Naira
- `NIO`: Nicaraguan Córdoba
- `NOK`: Norwegian Krone
- `NPR`: Nepalese Rupee
- `NZD`: New Zealand Dollar
- `OMR`: Omani Rial
- `PAB`: Panamanian Balboa
- `PEN`: Peruvian Sol
- `PGK`: Papua New Guinean Kina
- `PHP`: Philippine Peso
- `PKR`: Pakistani Rupee
- `PLN`: Polish Złoty
- `PYG`: Paraguayan Guaraní
- `QAR`: Qatari Riyal
- `RON`: Romanian Leu
- `RSD`: Serbian Dinar
- `RUB`: Russian Ruble
- `RWF`: Rwandan Franc
- `SAR`: Saudi Riyal
- `SBD`: Solomon Islands Dollar
- `SCR`: Seychellois Rupee
- `SDG`: Sudanese Pound
- `SEK`: Swedish Krona
- `SGD`: Singapore Dollar
- `SHP`: Saint Helena Pound
- `SLE`: Sierra Leonean Leone
- `SOS`: Somali Shilling
- `SRD`: Surinamese Dollar
- `SSP`: South Sudanese Pound
- `STN`: São Tomé and Príncipe Dobra
- `SYP`: Syrian Pound
- `SZL`: Swazi Lilangeni
- `THB`: Thai Baht
- `TJS`: Tajikistani Somoni
- `TMT`: Turkmenistani Manat
- `TND`: Tunisian Dinar
- `TOP`: Tongan Paʻanga
- `TRY`: Turkish Lira
- `TTD`: Trinidad and Tobago Dollar
- `TWD`: New Taiwan Dollar
- `TZS`: Tanzanian Shilling
- `UAH`: Ukrainian Hryvnia
- `UGX`: Ugandan Shilling
- `USD`: United States Dollar
- `UYU`: Uruguayan Peso
- `UZS`: Uzbekistani Sum
- `VES`: Venezuelan Sovereign Bolívar
- `VND`: Vietnamese Đồng
- `VUV`: Vanuatu Vatu
- `WST`: Samoan Tālā
- `XAF`: Central African CFA Franc
- `XCD`: Eastern Caribbean Dollar
- `XOF`: West African CFA Franc
- `XPF`: CFP Franc
- `YER`: Yemeni Rial
- `ZAR`: South African Rand
- `ZMW`: Zambian Kwacha
- `ZWG`: Zimbabwe Gold

*If you want to add another currency, please open an issue.*

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [changelog](changelog.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [contributing](.github/contributing.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](.github/security.md) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Marco Gava](https://github.com/macmotp)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](license.md) for more information.

###  Health Score

36

—

LowBetter than 82% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

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

Recently: every ~109 days

Total

7

Last Release

596d ago

Major Versions

v0.4.1 → v1.0.02024-09-29

### Community

Maintainers

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

---

Top Contributors

[![macmotp](https://avatars.githubusercontent.com/u/6443339?v=4)](https://github.com/macmotp "macmotp (11 commits)")

---

Tags

phpmoneycurrenciesmacmotp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

###  Alternatives

[cartalyst/converter

A framework agnostic measurement conversion and formatting package featuring multiple types of measurements and currency conversion.

88434.4k7](/packages/cartalyst-converter)[openbuildings/monetary

Useful tool for formatting and converting currencies

10207.6k1](/packages/openbuildings-monetary)[javadev/moneytostr-russian

The tool to convert amount to words in Ukrainian/English/Russian languages

421.2k](/packages/javadev-moneytostr-russian)[wujunze/money-wrapper

MoneyPHP Wrapper

113.8k](/packages/wujunze-money-wrapper)

PHPackages © 2026

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