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

ActiveLibrary

doxadoxa/money-lib
==================

Simple money library for PHP.

v1.4.6(5y ago)1102MITPHPPHP ^7.3CI failing

Since Feb 16Pushed 5y ago1 watchersCompare

[ Source](https://github.com/doxadoxa/money-lib)[ Packagist](https://packagist.org/packages/doxadoxa/money-lib)[ RSS](/packages/doxadoxa-money-lib/feed)WikiDiscussions master Synced today

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

MoneyLib for PHP
================

[](#moneylib-for-php)

[![Build Status](https://camo.githubusercontent.com/9e9f249513f48500ad42c38079e7edc9f3e72a356d259fb9121f088690eb54a2/68747470733a2f2f7472617669732d63692e6f72672f646f7861646f78612f6d6f6e65792d6c69622e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/doxadoxa/money-lib)

Simple implementation for Fouler Money Pattern with GMP. You can use this lib for cryptocurrencies also.

How to install
--------------

[](#how-to-install)

Install via composer:

```
composer require doxadoxa/money-lib
```

How to use
----------

[](#how-to-use)

### Basic

[](#basic)

Simple do like this:

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

$bitcoin = new Currency('BTC', 8);
$amount = Money::make( $bitcoin, 0.1858);
echo $amount->getAmount(); // (float) 0.1858
echo $amount->getStringAmount(); // (string) "18580000"
```

Also, you can make money from every precision you want:

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

$ethereum = new Currency('ETH', 18);
$amount = Money::make( $ethereum, 0.000000000000000005);
echo $amount->getAmount(); // (float) 5.0E-18
echo $amount->getStringAmount(); // (string) "5"
```

### Available operations

[](#available-operations)

You can use default math operations over the money space — addition and substraction. All operations are side-effect secure.

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

$ethereum = new Currency('ETH', 18);
$usd = new Currency('USD', 2);
$amount = Money::make( $ethereum, 0.05 );

// Add operation
$newAmount = $amount->add( Money::make( $ethereum, 0.005 ) );
echo $newAmount->getAmount(); // (float) 0.055

// Sub operation
$newAmount = $amount->sub( Money::make( $ethereum, 0.005 ) );
echo $newAmount->getAmount(); // (float) 0.045

// Comparisons
$amount = Money::make( $usd, 10 );
$newAmount = Money::make( $usd, 10);
$nullAmount = Money::make( $ethereum, 0);
$newNullAmount = Money::make( $usd, 0);

$amount->equals( $newAmount ); // (bool) true
$nullAmount->equals($newNullAmount); // (bool) true

$amount->strictEquals( $newAmount ); // (bool) true
$nullAmount->strictEquals($newNullAmount); // (bool) false

$newAmount = Money::make( $usd, 20 );
$amount->less( $newAmount ); // (bool) true
$amount->more( $newAmount ); // (bool) false
```

### ISO4217

[](#iso4217)

Library supports auto-detection for ISO4217 currencies to add some features, like symbol formatting (like changing USD symbol to $), default decimals count for currency and getting additional params like country or full name. You can access ISO4217 object via `getIso4217()` method on currency object.

### Formatting output

[](#formatting-output)

You can simply format you money with cast to string via `format` method.

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

$usd = new Currency('USD');
$money = Money::make( $usd, 1000 );
echo $money->format();// $ 1,000.00
```

Also, you can make you own formatter by inherit with `Formatter` class and make you own format. Or you can simple change format in formatters constructor:

```
use Money\Formatters\CurrencyFormatter;
use Money\Currency;
use Money\Money;

$usd = new Currency('USD');
$formatter = new CurrencyFormatter(":amount:symbol", '.', '', 0);
$usd->setFormatter( $formatter );
$money = Money::make( $usd, 1000);
echo $money->format(); // 1000$
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity61

Established project with proven stability

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

Recently: every ~0 days

Total

21

Last Release

2117d ago

### Community

Maintainers

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

---

Tags

moneycurrencylibrarycryptocurrency

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[ccxt/ccxt

A cryptocurrency trading API with more than 100 exchanges in JavaScript / TypeScript / Python / C# / PHP / Go

41.5k328.9k1](/packages/ccxt-ccxt)[brick/money

Money and currency library

1.9k37.9M102](/packages/brick-money)[florianv/swap

Exchange rates library for PHP

1.3k6.4M16](/packages/florianv-swap)[cknow/laravel-money

Laravel Money

1.0k4.3M22](/packages/cknow-laravel-money)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7825.3M18](/packages/akaunting-laravel-money)[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4235.0M21](/packages/kwn-number-to-words)

PHPackages © 2026

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