README.md 1021 Bytes
Newer Older
Mathias Verraes's avatar
Mathias Verraes committed
1
Money
Mathias Verraes's avatar
Mathias Verraes committed
2
=====
Mathias Verraes's avatar
Mathias Verraes committed
3

Mathias Verraes's avatar
Mathias Verraes committed
4
PHP 5.3+ library to make working with money safer, easier, and fun!
Mathias Verraes's avatar
Mathias Verraes committed
5

Mathias Verraes's avatar
Mathias Verraes committed
6
In short: You probably shouldn't represent monetary values by a float. Wherever 
Mathias Verraes's avatar
readme    
Mathias Verraes committed
7
8
you need to represent money, use this Money value object.

9
10
11
12
13
14
15
16
17
18
19
20
21
```php
<?php

use Money\Money;

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

list($part1, $part2, $part3) = $tenEur->allocate(array(1, 1, 1));
assert($part1->equals(Money::EUR(334)));
assert($part2->equals(Money::EUR(333)));
assert($part3->equals(Money::EUR(333)));
```
Mathias Verraes's avatar
readme    
Mathias Verraes committed
22

Mathias Verraes's avatar
link    
Mathias Verraes committed
23
The documentation is available at http://money.readthedocs.org
Mathias Verraes's avatar
Mathias Verraes committed
24

25
26
27
28
29
30
31
32
33
[![Build Status](https://secure.travis-ci.org/mathiasverraes/money.png)](http://travis-ci.org/mathiasverraes/money)

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

Install the library using [composer][1]. Add the following to your `composer.json`:

```json
{
34
35
36
    "require": {
        "mathiasverraes/money": "dev-master"
    },
37
38
39
40
41
42
43
44
45
46
47
    "minimum-stability": "dev"    
}
```

Now run the `install` command.

```sh
$ composer.phar install
```

[1]: http://getcomposer.org/