PHP implementation of Fowler's Money pattern

Installs: 1 749

Dependents: 1

Stars: 6

Watchers: 1

Forks: 90

2.0.3 2014-04-20 16:04 UTC


Fork from Mathias Verraes implementation of Fowley's money pattern.

The current version of the fork divverges from Fowley's pattern by using floats as parameters on the Money constructor. This was introduced in order to cater to the issue of large monetary entities overflowing PHP int size on 32 bits platforms. This will be dealt with on later releases of this fork, so expect API breakage on minor releases.

PHP 5.3+ library to make working with money safer, easier, and fun!

"If I had a dime for every time I've seen someone use FLOAT to store currency, I'd have $999.997634" -- Bill Karwin

In short: You shouldn't represent monetary values by a float. Wherever you need to represent money, use this Money value object.


use Money\Money;

$fiveEur = Money::EUR(5);
$tenEur = $fiveEur->add($fiveEur);

list($part1, $part2, $part3) = $tenEur->allocate(array(1, 1, 1));

The documentation is available at


Install the library using composer. Add the following to your composer.json:

    "require": {
        "hemeragestao/money": "2.0.*"

Now run the install command.

$ composer.phar install

Added Features

This fork replaces the maping of currencies from a simple ISO 4217 map from with the data contained in Ruby's Money mapping. This allows for a few additional features, including generating formatted output string for the Money objects. Also, the Money object constructor takes a float parameter, using it as the amount instead of units. This will be changed on later releases.


use Money\Money;

echo Money::EUR(5.32);


€ 5.32


See MoneyBundle or TbbcMoneyBundle for Symfony integration.