moneyphp/money
moneyphp/money is a PHP value-object library for safe money handling without floats. Uses string-based big integers, supports arithmetic, allocation, currencies/ISO repositories, formatting (incl. intl), JSON serialization, and exchange rates. Requires BCMath.
999.99 + 0.01 ≠ 1000.00), critical for payment systems, invoicing, or tax engines.voutzinos/swap) enables real-time FX rates without third-party APIs.float-based money storage in databases/APIs with this package’s immutable Money objects.CurrencyRepository interface.Money::allocate).min, max, avg) for financial dashboards.Adopt If:
Look Elsewhere If:
web3php/web3.php or paritytech/parity-php.decimal.js or python-decimal instead.*"This package solves a hidden technical debt bomb in our financial systems. Right now, storing $1000 as a float in our database could silently become $999.9976 due to rounding errors—costing us money in transactions or compliance fines. moneyphp/money fixes this by using strings for precision (like banks do) and adds superpowers:
*"This is the Fowler Money Pattern implemented in PHP—what we’ve been missing for years. Key wins:
float hacks: All calculations use arbitrary-precision strings (BCMath/GMP fallback).sum, avg) for analytics.Money::EUR(500)->add(Money::EUR(500)) always equals 1000 (no 999.999999999999).
Migration path:float money fields with Money objects in new features.Teller class to help legacy apps transition.DECIMAL fields with strings (e.g., amount → amount_string) for long-term safety.
Tradeoffs:float for trivial math (but negligible for real-world use)."**"This package eliminates rounding errors in financial reports, which is critical for:
Money objects log exact transaction values.allocate() reveals suspicious splits).
Example: If we allocate $1000 into 3 parts with ratios [1, 1, 1], this package guarantees exact splits of $333.33, $333.33, and $333.34—no floating-point approximations."*How can I help you explore Laravel packages today?