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

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

ricklukewebdev/money
====================

A small package to handle money values correctly in PHP.

v0.1.0(4y ago)07MITPHPPHP ^7.1 || ^8.0

Since Aug 12Pushed 3y ago1 watchersCompare

[ Source](https://github.com/ricklukewebdev/money)[ Packagist](https://packagist.org/packages/ricklukewebdev/money)[ RSS](/packages/ricklukewebdev-money/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Money
=====

[](#money)

[![Latest Version on Packagist](https://camo.githubusercontent.com/8c8a20ee38ec7fbaa634487c721eb742f17a7bdb7066f11235c34368eb8d3092/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7269636b6c756b657765626465762f6d6f6e65792e7376673f7374796c653d666c6174)](https://packagist.org/packages/ricklukewebdev/money)

Do you recognize the problem of retrieving money values from forms in various formats, and are you having trouble to handle these values correctly or storing them in the database?

That's exactly the issue that this small library solves. And it's done very easily:

```
use RickLuke\Money\Money;

$value = Money::convert("€ 249,49"); // 249.49
```

Additionally, there are some basic calculation methods available that allow for manipulating the stored value.

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

[](#installation)

The project can be installed using Composer:

```
composer require ricklukewebdev/money
```

Usage
-----

[](#usage)

At the top of your PHP-file, simply import the package:

```
use RickLuke\Money\Money;
```

From now on, you can create a new Money instance as follows:

```
$money = Money::create("€ 29,50");
```

To return the value as a float, you can use the *toFloat()* method:

```
echo $money->toFloat(); // 29.5
```

There is also a *format()* method available (see below).

### Manipluation

[](#manipluation)

Values can be manipulated in a couple of ways.

*The values in this example are based on the value mentioned earlier.*

```
// Adding
$money->add(2); // 31.5

// Subtracting
$money->subtract("5,5"); // 26

// Multiplying
$money->multiply(2.5); // 65

// Dividing
$money->divide(3); // 21.666666666667

// Working with percentages
$money->addPercentage(21); // 26.216666666667
$money->subtractPercentage("15%"); // 22.797101449275
```

### Method chaining

[](#method-chaining)

All of the above methods can be chained like so:

```
$money = Money::create(20)
  ->add("€ 5,75")
  ->addPercentage("17.5%")
  ->toFloat(); // 30.25625
```

### Currencies

[](#currencies)

When creating a new Money instance, optionally a currency symbol can be provided as the second parameter. This symbol can be returned when using the *format()* method:

```
$money = Money::create(275, "€");
```

### Formatting

[](#formatting)

The result can be outputted as float, or can be formatted using the *format()* method.

```
use RickLuke\Money\Money;
use RickLuke\Money\CurrencyPosition;

$money = Money::create(19.989, "€");

// Return as float
echo $money->toFloat(); // 100

// Return formatted
echo $money->format(CurrencyPosition::LEFT, 2, ',', '.'); // € 19,99
```

The *format()* method takes the required position of the currency symbol as the first argument. The other arguments are similar to PHP's default *number\_format()* method.

```
// Left
echo Money::create(19.989, "€")
  ->format(CurrencyPosition::LEFT, 2, ',', '.'); // € 19,99

// Right
echo Money::create(19.989, "$")
  ->format(CurrencyPosition::RIGHT, 2, '.', ','); // 19.99 $

// Hide
echo Money::create(19.989, "USD")
  ->format(CurrencyPosition::NONE, 2, '.', ','); // 19.99
```

If preferred, the space between the currency symbol and the amount can be removed using the *removeSpace()* method:

```
echo Money::create(19.989, "€")
  ->removeSpace()
  ->format(CurrencyPosition::LEFT, 2, ',', '.'); // €19,99
```

Changelog
---------

[](#changelog)

Please take a look at the actual [CHANGELOG](CHANGELOG.md).

License
-------

[](#license)

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

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 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

Unknown

Total

1

Last Release

1785d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

moneycurrencyfloats

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[brick/money

Money and currency library

1.9k41.8M152](/packages/brick-money)[florianv/swap

PHP currency conversion library for retrieving exchange rates from 30+ providers, with caching and fallback.

1.3k6.8M23](/packages/florianv-swap)[cknow/laravel-money

Laravel Money

1.0k4.8M30](/packages/cknow-laravel-money)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7865.8M46](/packages/akaunting-laravel-money)[kwn/number-to-words

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

4375.4M23](/packages/kwn-number-to-words)[torann/currency

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

4031.1M6](/packages/torann-currency)

PHPackages © 2026

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