Money is a PHP library that implements Fowler's Money pattern to represent monetary values safely and accurately.
The problem Money solves is the widespread practice of using floating-point numbers to store currency values, which leads to precision errors and incorrect calculations. The library provides a Money value object that uses strings internally to support unlimited precision arithmetic. It requires the BCMath PHP extension and performs calculations using available big-integer libraries transparently, falling back to plain PHP when necessary.
Developers should adopt this library when building any PHP application that handles monetary transactions or financial calculations. It suits projects ranging from e-commerce platforms to accounting systems where precision is critical. The tool includes built-in support for currency repositories with ISO currencies, money formatting with internationalization support, and currency exchange functionality including integration with the Swap library for real-time exchange rates. JSON serialization is also provided for API responses and data storage.
The project maintains a test-driven development approach using PHPUnit and enforces consistent code style through automated tooling. Contributions are actively welcomed with clear expectations around testing and code quality standards. The library maintains compatibility with actively supported PHP versions while providing older versions for projects on legacy PHP releases.