PHPackages                             datailor/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. datailor/laravel-money

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

datailor/laravel-money
======================

Laravel Money

7.0.1(3y ago)0527MITPHPPHP ^7.3|^8.0

Since Sep 27Pushed 3y agoCompare

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

READMEChangelog (1)Dependencies (8)Versions (2)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/5dcea9aff4409aa2e7118037049afe70c9004bb87334c79bb280668b4c2b2c97/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f34303031383132332f736869656c643f7374796c653d666c6174)](https://github.styleci.io/repos/40018123)[![codecov](https://camo.githubusercontent.com/e3494f2821f6808f678b9cdbbaed7e4423477599557b340e958b958c91429356/68747470733a2f2f636f6465636f762e696f2f67682f636b6e6f772f6c61726176656c2d6d6f6e65792f67726170682f62616467652e737667)](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/)

> ⚠️ Temporary fork from cknow/laravel-money

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

[](#installation)

Run the following command from you terminal:

```
composer require datailor/laravel-money
```

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

```
"datailor/laravel-money": "^7.0"
```

then run `composer update`

Usage
-----

[](#usage)

```
use Cknow\Money\Money;

echo Money::USD(500); // $5.00
echo Money::USD(500, true); // $500.00 force decimals
```

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'),
    'defaultFormatter' => null,
    '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
Money::isValidCurrency('USD'); // true
Money::isValidCurrency('FAIL'); // false
Money::getISOCurrencies(); // Load ISO currencies

// 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)->formatByCurrencySymbol(); // $5.00
Money::USD(500)->formatByCurrencySymbol(true); // 5.00$
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
```

Rules
-----

[](#rules)

Below is a list of all available validation rules and their function:

### currency

[](#currency)

The field under validation must be a valid currency.

```
Validator::make([
  'currency1' => 'USD',
  'currency2' => 'EUR',
  'currency3' => new \Money\Currency('BRL'),
], [
  'currency1' => new \Cknow\Money\Rules\Currency(),
  'currency2' => new \Cknow\Money\Rules\Currency(),
  'currency3' => 'currency',
]);
```

### money

[](#money)

The field under validation must be a valid money.

```
Validator::make([
  'money1' => '$10.00'
  'money2' => '€10.00',
  'money3' => 'R$10,00',
  'money4' => '$10.00'
  'money5' => '€10.00',
  'money6' => 'R$10,00',
], [
  'money1' => new \Cknow\Money\Rules\Money(),
  'money2' => new \Cknow\Money\Rules\Money('EUR'), // forcing currency
  'money3' => new \Cknow\Money\Rules\Money('BRL', 'pt_BR'), // forcing currency and locale
  'money4' => 'money',
  'money5' => 'money:EUR', // forcing currency
  'money6' => 'money:BRL,pt_BR', // forcing currency and locale
]);
```

Casts
-----

[](#casts)

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

```
use Cknow\Money\Casts\MoneyDecimalCast;
use Cknow\Money\Casts\MoneyIntegerCast;
use Cknow\Money\Casts\MoneyStringCast;

protected $casts = [
    // cast money as decimal using the currency defined in the package config
    'money' => MoneyDecimalCast::class,
    // cast money as integer using the defined currency
    'money' => MoneyIntegerCast::class . ':AUD',
    // cast money as string using the currency defined in the model attribute 'currency'
    'money' => MoneyStringCast::class . ':currency',
    // cast money as decimal using the defined currency and forcing decimals
    'money' => MoneyDecimalCast::class . ':USD,true',
];
```

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() // To use default currency present in `config/money.php`
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() // To use default currency present in `config/money.php`
@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

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 92.7% 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

Unknown

Total

1

Last Release

1322d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/0a71b6fa273bb01bb30f80df2a88193b42c0659b9bb1a62d56e4028cc7410fed?d=identicon)[marwins](/maintainers/marwins)

---

Top Contributors

[![ricardogobbosouza](https://avatars.githubusercontent.com/u/13064722?v=4)](https://github.com/ricardogobbosouza "ricardogobbosouza (293 commits)")[![lloricode](https://avatars.githubusercontent.com/u/8251344?v=4)](https://github.com/lloricode "lloricode (4 commits)")[![marwins](https://avatars.githubusercontent.com/u/20090626?v=4)](https://github.com/marwins "marwins (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)")[![niklaslovgren](https://avatars.githubusercontent.com/u/47850368?v=4)](https://github.com/niklaslovgren "niklaslovgren (1 commits)")[![andreiio](https://avatars.githubusercontent.com/u/1569300?v=4)](https://github.com/andreiio "andreiio (1 commits)")[![ShamarKellman](https://avatars.githubusercontent.com/u/4120411?v=4)](https://github.com/ShamarKellman "ShamarKellman (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)")[![sudkumar](https://avatars.githubusercontent.com/u/6812992?v=4)](https://github.com/sudkumar "sudkumar (1 commits)")[![rez1dent3](https://avatars.githubusercontent.com/u/5111255?v=4)](https://github.com/rez1dent3 "rez1dent3 (1 commits)")[![cerbero90](https://avatars.githubusercontent.com/u/5838106?v=4)](https://github.com/cerbero90 "cerbero90 (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)")

---

Tags

laravelmoneycurrency

###  Code Quality

TestsPHPUnit

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/datailor-laravel-money/health.svg)](https://phpackages.com/packages/datailor-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)[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)[wujunze/money-wrapper

MoneyPHP Wrapper

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

PHPackages © 2026

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