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.
brick/math) align perfectly with Laravel’s need for reliable financial calculations.CashContext for CHF rounding, AutoContext for dynamic precision), which is critical for multi-currency systems or compliance with regional financial rules.Money objects prevent side effects, simplifying state management in Laravel services/repositories.Cart, Order, Payment models).numeric|min:0 for amounts) with strict currency/currency-mismatch checks.0.x.* mitigates this.RationalMoney).CurrencyConverter or integrated with a service like laravel-money?decimal(10,2) fields) migrate to Money objects?RationalMoney precision)?€1,000.00 vs. 1,000.00 USD)? If so, how will this integrate with Laravel’s localization?composer require brick/money.float amounts with Money objects in OrderService, PaymentGateway integrations.MoneyBag for multi-currency financial reports.Money objects (e.g., validateMoney(Money::of($request->amount, $request->currency))).Money objects in new financial features (e.g., subscriptions, refunds) without touching legacy code.Money objects to services.amount_in_cents).Money and legacy float values (e.g., Money::fromLegacyFloat($amount, $currency)).Money-based operations.Money objects (e.g., JSON API serialization/deserialization).amount_cents for USD) to avoid precision loss."123.45") or JSON objects ({"amount": "123.45", "currency": "USD"}).Money objects to JSON with toString() or custom encoders.Money and external APIs (e.g., Stripe, PayPal).Money operations in a sandbox (e.g., order calculations, tax logic).Money facade or service container.Money operations with/without GMP/BCMath.brick/money for breaking changes (e.g., currency updates). Use Laravel’s composer.json conflict rules to enforce version locks.IsoCurrencyProvider is kept up-to-date with ISO 4217 changes. Automate updates via CI/CD.Money-specific behaviors (e.g., rounding modes, context usage) in API contracts and internal wikis.Money::toString() for logging.RoundingMode::HalfUp for taxes).CurrencyMismatchException in PaymentService).Money vs. legacy float usage (e.g., avoid Money::of(0.1); use Money::ofMinor(10) for USD).Currency objects (e.g., Currency::of('USD')) if loaded frequently.float for financial amounts.Money objects in input/output layers.CZK → CZK with new minor unit).Digital Euro).SplitMode results) and test thoroughly.Money facade (e.g., Money::usd($amount)).float-based code.CashContext for CHF).Money usage.Money::debug($money)).How can I help you explore Laravel packages today?