README.md 1.16 KB
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

4
[![Build Status](https://api.travis-ci.org/mathiasverraes/money.png?branch=master)](http://travis-ci.org/mathiasverraes/money)
5

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

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

11
12
13
14
15
16
17
18
19
20
21
22
23
```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
24

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

27
28
29
30
31
32
33
34

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

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

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

Now run the `install` command.

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

48
49
50
51
52
53
54
55
Integration
-----------

See [`MoneyBundle`][2] for [Symfony integration][3].

[1]: http://getcomposer.org/
[2]: https://github.com/pink-tie/MoneyBundle/
[3]: http://symfony.com/