A PHP library implementing Fowler's Money pattern for safe, precise monetary value representation and operations.
MoneyPHP/Money is a PHP library that provides an immutable value object for representing and manipulating monetary values. It solves the common problem of floating-point inaccuracies in financial calculations by using string-based internal representation to ensure precision and safety. The library includes features for formatting, currency management, and exchange operations.
PHP developers building applications that handle financial transactions, e-commerce systems, accounting software, or any system requiring precise monetary calculations. It is particularly useful for those who need to avoid floating-point errors and ensure data integrity in currency operations.
Developers choose this library because it enforces safe monetary handling through immutable value objects and big integer support, preventing common pitfalls like floating-point representation. Its comprehensive feature set, including built-in currency data, formatting, and exchange integrations, offers a robust, standardized solution for financial computations in PHP.
PHP implementation of Fowler's Money pattern.
Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.
Uses string-based internal representation to avoid floating-point errors, ensuring accurate financial calculations as highlighted in the README's philosophy against using floats for currency.
Includes built-in ISO currency repositories and international money formatting, making it easy to handle multiple currencies without external data sources.
Supports currency conversion with integrations like Swap for exchange rates, providing flexible and extendable money exchange capabilities.
Enforces data integrity through immutable money objects, preventing accidental modifications in financial transactions as per the library's design.
Requires the BCMath PHP extension, which may not be available in all hosting environments and adds an installation barrier, as noted in the requirements.
String-based arithmetic can be slower than native float operations, potentially impacting performance in high-throughput applications compared to simpler approaches.
Features like exchange rate integration require additional dependencies and configuration, such as Swap, increasing setup time and complexity.