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.
Monetization & Payments Features
Roadmap Prioritization
Money object to ensure thread-safe operations in high-concurrency systems (e.g., payment processors).Use Cases
allocate() (e.g., 60/30/10 splits).CryptoCurrencies class.IntlLocalizedDecimalFormatter).Money pattern via the Teller adapter for existing float-based systems.Adopt if:
0.1 + 0.2 !== 0.3 in floats breaks your logic).Swap or Exchanger integrations).Look elsewhere if:
decimal.Decimal, Java’s BigDecimal).brianium/paragonie_number exist for older PHP).*"This package eliminates a critical technical debt risk: floating-point errors in financial calculations. Imagine a $100 invoice with a 10% discount—using floats, the system might charge $99.997634 instead. With moneyphp/money, we guarantee precise, auditable transactions while accelerating development. It’s a drop-in solution for:
*"This is the Fowler Money Pattern implemented in PHP, solving:
Money::EUR(500)->add(Money::EUR(500)) === Money::EUR(1000)).Money::BTC(0.5)).Swap or Exchanger for dynamic conversions.gmp or brianium/paragonie_number as fallbacks.
Next steps:composer.json (composer require moneyphp/money).Money objects (e.g., Money::USD(1000) instead of 1000.00).allocate() for splits, Converter for exchanges, and IntlLocalizedDecimalFormatter for localization.
ROI: Faster dev, fewer bugs, and future-proof financial logic."*How can I help you explore Laravel packages today?