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

ActiveLibrary

ogestor/laravel-money
=====================

Laravel Money

v6.1.0(5y ago)05MITPHPPHP ^7.3|^8.0

Since Sep 14Pushed 5y agoCompare

[ Source](https://github.com/ogestor/laravel-money)[ Packagist](https://packagist.org/packages/ogestor/laravel-money)[ Docs](https://github.com/cknow/laravel-money)[ RSS](/packages/ogestor-laravel-money/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (1)Dependencies (7)Versions (33)Used By (0)

Laravel Money
=============

[](#laravel-money)

[![Latest Stable Version](https://camo.githubusercontent.com/8b9ea3deead76166bfba41a35e18c29647a38967d362fff3cc3e4a45f21f81be/68747470733a2f2f706f7365722e707567782e6f72672f636b6e6f772f6c61726176656c2d6d6f6e65792f76657273696f6e)](https://packagist.org/packages/cknow/laravel-money)[![Total Downloads](https://camo.githubusercontent.com/102d6bd84cd52121d4d0e25fc4d9c3b36bce43e5c31c93a55d8d4a78884181cd/68747470733a2f2f706f7365722e707567782e6f72672f636b6e6f772f6c61726176656c2d6d6f6e65792f646f776e6c6f616473)](https://packagist.org/packages/cknow/laravel-money)[![tests](https://github.com/cknow/laravel-money/workflows/tests/badge.svg)](https://github.com/cknow/laravel-money/actions)[![StyleCI](https://camo.githubusercontent.com/2bc0c0553d0145f7871581eef84d78a98b6c568ba6599377f917dc2055a99289/68747470733a2f2f7374796c6563692e696f2f7265706f732f34303031383132332f736869656c643f7374796c653d666c6174)](https://styleci.io/repos/40018123)[![codecov](https://camo.githubusercontent.com/7a92a333b2922134d7b529608353b6a6d2a60774b57100f5f40983743f7b4ace/68747470733a2f2f636f6465636f762e696f2f67682f636b6e6f772f6c61726176656c2d6d6f6e65792f6272616e63682f6d61737465722f67726170682f62616467652e737667)](https://codecov.io/gh/cknow/laravel-money)[![License](https://camo.githubusercontent.com/82fa87f9c8bbc19ff0ea486868c85a1c784a687782e7a8d9af33dd511c190696/68747470733a2f2f706f7365722e707567782e6f72672f636b6e6f772f6c61726176656c2d6d6f6e65792f6c6963656e7365)](https://packagist.org/packages/cknow/laravel-money)

> **Note:** This project abstracts [MoneyPHP](http://moneyphp.org/)

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

[](#installation)

Run the following command from you terminal:

```
composer require ogestor/laravel-money
```

or add this to require section in your composer.json file:

```
"ogestor/laravel-money": "~6.0"
```

then run `composer update`

Usage
-----

[](#usage)

```
use Cknow\Money\Money;

echo Money::USD(500); // $5.00
```

Configuration
-------------

[](#configuration)

The defaults are set in `config/money.php`. Copy this file to your own config directory to modify the values. You can publish the config using this command:

```
php artisan vendor:publish --provider="Cknow\Money\MoneyServiceProvider"
```

This is the contents of the published file:

```
return [
    /*
     |--------------------------------------------------------------------------
     | Laravel money
     |--------------------------------------------------------------------------
     */
    'locale' => config('app.locale', 'en_US'),
    'defaultCurrency' => config('app.currency', 'USD'),
    'currencies' => [
        'iso' => ['RUB', 'USD', 'EUR'],  // 'all' to choose all ISOCurrencies
        'bitcoin' => ['XBT'], // 'all' to choose all BitcoinCurrencies
        'custom' => [
            'MY1' => 2,
            'MY2' => 3
        ]
    ]
];
```

Advanced Usage
--------------

[](#advanced-usage)

> See [MoneyPHP](http://moneyphp.org/) for more information

```
use Cknow\Money\Money;

Money::USD(500)->add(Money::USD(500)); // $10.00
Money::USD(500)->add(Money::USD(500), Money::USD(500)); // $15.00
Money::USD(500)->subtract(Money::USD(400)); // $1.00
Money::USD(500)->subtract(Money::USD(200), Money::USD(100)); // $2.00
Money::USD(500)->multiply(2); // $10.00
Money::USD(1000)->divide(2); // $5.00
Money::USD(830)->mod(Money::USD(300)); // $2.30 -> Money::USD(230)
Money::USD(-500)->absolute(); // $5.00
Money::USD(500)->negative(); // $-5.00
Money::USD(30)->ratioOf(Money::USD(2)); // 15
Money::USD(500)->isSameCurrency(Money::USD(100)); // true
Money::USD(500)->equals(Money::USD(500)); // true
Money::USD(500)->greaterThan(Money::USD(100)); // true
Money::USD(500)->greaterThanOrEqual(Money::USD(500)); // true
Money::USD(500)->lessThan(Money::USD(1000)); // true
Money::USD(500)->lessThanOrEqual(Money::USD(500)); // true
Money::USD(500)->isZero(); // false
Money::USD(500)->isPositive(); // true
Money::USD(500)->isNegative(); // false
Money::USD(500)->getMoney(); // Instance of \Money\Money

// Aggregation
Money::min(Money::USD(100), Money::USD(200), Money::USD(300)); // Money::USD(100)
Money::max(Money::USD(100), Money::USD(200), Money::USD(300)); // Money::USD(300)
Money::avg(Money::USD(100), Money::USD(200), Money::USD(300)); // Money::USD(200)
Money::sum(Money::USD(100), Money::USD(200), Money::USD(300)); // Money::USD(600)

// Formatters
Money::USD(500)->format(); // $5.00
Money::USD(199)->format(null, null, \NumberFormatter::DECIMAL); // 1,99
Money::XBT(41000000)->formatByBitcoin(); // \xC9\x830.41
Money::USD(500)->formatByDecimal(); // 5.00
Money::USD(500)->formatByIntl(); // $5.00
Money::USD(199)->formatByIntl(null, null, \NumberFormatter::DECIMAL); // 1,99
Money::USD(500)->formatByIntlLocalizedDecimal(); // $5.00
Money::USD(199)->formatByIntlLocalizedDecimal(null, null, \NumberFormatter::DECIMAL) // 1.99

// Parsers
Money::parse('$1.00'); // Money::USD(100)
Money::parseByBitcoin("\xC9\x830.41"); // Money::XBT(41000000)
Money::parseByDecimal('1.00', 'USD'); // Money::USD(100)
Money::parseByIntl('$1.00'); // Money::USD(100)
Money::parseByIntlLocalizedDecimal('1.00', 'USD'); // Money::USD(100)
```

### Create your formatter

[](#create-your-formatter)

```
class MyFormatter implements \Money\MoneyFormatter
{
    public function format(\Money\Money $money)
    {
        return 'My Formatter';
    }
}

Money::USD(500)->formatByFormatter(new MyFormatter()); // My Formatter
```

Casts
-----

[](#casts)

At this stage the cast can be defined in the following ways:

```
protected $casts = [
    // cast money using the currency defined in the package config
    'money' => MoneyCast::class,
    // cast money using the defined currency
    'money' => MoneyCast::class . ':AUD',
    // cast money using the currency defined in the model attribute 'currency'
    'money' => MoneyCast::class . ':currency',
];
```

In the example above, if the model attribute `currency` is `null`, the currency defined in the package configuration is used instead.

Setting money can be done in several ways:

```
$model->money = 10; // 10.00 USD or any other currency defined
$model->money = 10.23; // 10.23 USD or any other currency defined
$model->money = 'A$10'; // 10.00 AUD
$model->money = '1,000.23'; // 1000.23 USD or any other currency defined
$model->money = '10'; // 0.10 USD or any other currency defined
$model->money = Money::EUR(10); // 10 EUR
```

When we pass the model attribute holding the currency, such attribute is updated as well when setting money:

```
$model->currency; // null
$model->money = '€13';
$model->currency; // 'EUR'
$model->money->getAmount(); // '1300'
```

Helpers
-------

[](#helpers)

```
currency('USD');
money(500); // To use default currency present in `config/money.php`
money(500, 'USD');

// Aggregation
money_min(money(100, 'USD'), money(200, 'USD'), money(300, 'USD')); // Money::USD(100)
money_max(money(100, 'USD'), money(200, 'USD'), money(300, 'USD')); // Money::USD(300)
money_avg(money(100, 'USD'), money(200, 'USD'), money(300, 'USD')); // Money::USD(200)
money_sum(money(100, 'USD'), money(200, 'USD'), money(300, 'USD')); // Money::USD(600)

// Parsers
money_parse('$5.00'); // Money::USD(500)
money_parse_by_bitcoin("\xC9\x830.41"); // Money::XBT(41000000)
money_parse_by_decimal('1.00', 'USD'); // Money::USD(100)
money_parse_by_intl('$1.00'); // Money::USD(100)
money_parse_by_intl_localized_decimal('1.00', 'USD'); // Money::USD(100)
```

Blade Extensions
----------------

[](#blade-extensions)

```
@currency('USD')
@money(500) // To use default currency present in `config/money.php`
@money(500, 'USD')

// Aggregation
@money_min(@money(100, 'USD'), @money(200, 'USD'), @money(300, 'USD')) // Money::USD(100)
@money_max(@money(100, 'USD'), @money(200, 'USD'), @money(300, 'USD')) // Money::USD(300)
@money_avg(@money(100, 'USD'), @money(200, 'USD'), @money(300, 'USD')) // Money::USD(200)
@money_sum(@money(100, 'USD'), @money(200, 'USD'), @money(300, 'USD')) // Money::USD(600)

// Parsers
@money_parse('$5.00') // Money::USD(500)
@money_parse_by_bitcoin("\xC9\x830.41") // Money::XBT(41000000)
@money_parse_by_decimal('1.00', 'USD') // Money::USD(100)
@money_parse_by_intl('$1.00') // Money::USD(100)
@money_parse_by_intl_localized_decimal('1.00', 'USD') // Money::USD(100)
```

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity79

Established project with proven stability

 Bus Factor1

Top contributor holds 92.5% 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 ~66 days

Recently: every ~61 days

Total

32

Last Release

1828d ago

Major Versions

v1.0.3 → v2.0.02017-09-05

v2.4.0 → v3.0.02018-04-02

v3.8.1 → v4.0.02020-03-06

v4.0.0 → v5.0.02020-06-04

v5.0.1 → v6.0.02020-09-09

PHP version history (9 changes)v0.1.0PHP &gt;=5.5.9

v2.0.0PHP &gt;=7.0

v2.2.0PHP ~7.0

v3.0.0PHP ~7.1

v3.4.0PHP ^7.1

v4.0.0PHP ^7.2

v5.0.0PHP ^7.2.5

v6.0.0PHP ^7.3

v6.1.0PHP ^7.3|^8.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/5c8c9cf1e0ca736e0fc81ccedf7a1cf039821f9aaacfa93a6b9fcab6076e27b2?d=identicon)[ogestor](/maintainers/ogestor)

---

Top Contributors

[![ricardogobbosouza](https://avatars.githubusercontent.com/u/13064722?v=4)](https://github.com/ricardogobbosouza "ricardogobbosouza (246 commits)")[![heliopassarelin](https://avatars.githubusercontent.com/u/49026132?v=4)](https://github.com/heliopassarelin "heliopassarelin (4 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (3 commits)")[![tymondesigns](https://avatars.githubusercontent.com/u/1801923?v=4)](https://github.com/tymondesigns "tymondesigns (3 commits)")[![russofinn](https://avatars.githubusercontent.com/u/16693017?v=4)](https://github.com/russofinn "russofinn (2 commits)")[![rez1dent3](https://avatars.githubusercontent.com/u/5111255?v=4)](https://github.com/rez1dent3 "rez1dent3 (1 commits)")[![Skullbock](https://avatars.githubusercontent.com/u/1104083?v=4)](https://github.com/Skullbock "Skullbock (1 commits)")[![subdesign](https://avatars.githubusercontent.com/u/691695?v=4)](https://github.com/subdesign "subdesign (1 commits)")[![niklaslovgren](https://avatars.githubusercontent.com/u/47850368?v=4)](https://github.com/niklaslovgren "niklaslovgren (1 commits)")[![DavidLambauer](https://avatars.githubusercontent.com/u/1841317?v=4)](https://github.com/DavidLambauer "DavidLambauer (1 commits)")[![Kurre](https://avatars.githubusercontent.com/u/1389199?v=4)](https://github.com/Kurre "Kurre (1 commits)")[![markahesketh](https://avatars.githubusercontent.com/u/1269894?v=4)](https://github.com/markahesketh "markahesketh (1 commits)")[![andreiio](https://avatars.githubusercontent.com/u/1569300?v=4)](https://github.com/andreiio "andreiio (1 commits)")

---

Tags

laravelmoneycurrency

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[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)[laravel/cashier

Laravel Cashier provides an expressive, fluent interface to Stripe's subscription billing services.

2.5k25.9M107](/packages/laravel-cashier)[laravel/cashier-paddle

Cashier Paddle provides an expressive, fluent interface to Paddle's subscription billing services.

264778.4k3](/packages/laravel-cashier-paddle)[torann/currency

This provides Laravel with currency functions such as currency formatting and conversion using up-to-date exchange rates.

4081.1M6](/packages/torann-currency)[casinelli/currency

Handles currency for Laravel 5.

1911.8k](/packages/casinelli-currency)

PHPackages © 2026

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