brick/money
Brick\Money is a PHP library for precise, immutable money and currency values. It provides exact arithmetic (no float errors), explicit rounding control, and supports large amounts via brick/math, with optional GMP/BCMath acceleration.
RationalMoney for high-precision intermediate calculations (e.g., actuarial models).Adopt if:
bcmath/GMP dependencies are acceptable).Look elsewhere if:
decimal.Decimal or Java’s BigDecimal may fit better).web3.php).*"This package solves a critical technical debt risk in our financial systems. Currently, floating-point errors in PHP could silently corrupt transaction data—costing us in disputes, compliance fines, or lost revenue. Brick\Money guarantees exact arithmetic for all monetary operations, just like a bank’s ledger. For example:
*"Brick\Money is a drop-in replacement for PHP’s native money handling, offering:
MoneyBag.float/int money values with Money objects in models/DTOs.Money::of(), Money::ofMinor()) for creation.$total->plus($tax)->minus($discount)).
Tradeoffs:brick/math (lightweight) and optional ext-gmp/ext-bcmath for speed.
Example win: If we switch our billing system to this, we’d eliminate the 3% error rate in high-precision invoices—worth the 2-day dev effort."*How can I help you explore Laravel packages today?