Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Money Laravel Package

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Precision Financial Calculations: Eliminates floating-point rounding errors in monetary operations (e.g., invoicing, tax calculations, or multi-currency transactions), ensuring compliance with financial regulations.
  • Multi-Currency Support: Enables seamless handling of cross-currency operations (e.g., e-commerce platforms, global payment systems, or FX trading tools) with strict validation.
  • Custom Rounding Rules: Supports business-specific rounding logic (e.g., cash rounding for Swiss Francs or custom scales for internal accounting).
  • Immutable Money Objects: Safeguards against unintended state changes in financial workflows (e.g., audit trails, transaction logs, or immutable ledgers).
  • Advanced Allocation Logic: Facilitates complex profit-sharing, tax distribution, or revenue splits (e.g., SaaS subscription models, affiliate payouts, or crowdfunding platforms).
  • Build vs. Buy: Avoids reinventing financial math wheels, reducing dev time and technical debt while leveraging a battle-tested, ISO 4217-compliant library.
  • Roadmap Priorities:
    • Phase 1: Integrate into core financial workflows (e.g., order processing, billing).
    • Phase 2: Extend to multi-currency dashboards or reporting tools.
    • Phase 3: Explore RationalMoney for high-precision intermediate calculations (e.g., actuarial models).

When to Consider This Package

  • Adopt if:

    • Your app handles monetary values with precision requirements (e.g., >$1M transactions, tax calculations, or fractional currencies like JPY).
    • You need multi-currency support with strict validation (e.g., global checkout, FX conversions).
    • Your team lacks financial math expertise but requires accurate arithmetic (e.g., startups, non-fintech products).
    • You’re using Laravel/PHP and want to avoid floating-point pitfalls (e.g., bcmath/GMP dependencies are acceptable).
    • Your use case involves complex allocations (e.g., revenue splits, tip pooling, or dynamic pricing).
  • Look elsewhere if:

    • You only need basic arithmetic (e.g., simple price tags) and can tolerate floating-point errors.
    • Your stack is non-PHP (e.g., Python’s decimal.Decimal or Java’s BigDecimal may fit better).
    • You require blockchain-level precision (e.g., cryptocurrency; consider libraries like web3.php).
    • Your team prefers proprietary solutions (e.g., Stripe’s SDK for payment-specific logic).

How to Pitch It (Stakeholders)

For Executives:

*"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:

  • E-commerce: No more ‘off-by-a-penny’ errors in cart totals or refunds.
  • Global Payments: Seamless multi-currency math without manual validation.
  • Compliance: Audit-ready precision for tax reports or regulatory filings. It’s a one-time integration that eliminates recurring bugs, reduces fraud risk, and future-proofs our financial logic. The MIT license and 1.9K+ stars mean it’s production-ready and community-backed."*

For Engineers:

*"Brick\Money is a drop-in replacement for PHP’s native money handling, offering:

  • Immutable objects: Safe for concurrent operations (e.g., microservices).
  • Context-aware rounding: Supports cash rounding (e.g., CHF), custom scales, or auto-scaling for intermediate calculations.
  • Advanced ops: Split payments, allocate profits by ratios, or handle mixed currencies via MoneyBag.
  • Performance: Optimized with GMP/BCMath (optional) for heavy workloads. Migration path:
  1. Replace float/int money values with Money objects in models/DTOs.
  2. Use factory methods (Money::of(), Money::ofMinor()) for creation.
  3. Update arithmetic to chain methods (e.g., $total->plus($tax)->minus($discount)). Tradeoffs:
  • Slightly verbose syntax (e.g., explicit rounding modes).
  • Requires PHP 8.2+ (or legacy versions for older stacks). Dependencies: Only 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."*
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
nexmo/api-specification
capell-app/block-library
axium/identity
cetria/laravel-dummy-models
cetria/reflection-helper
agropredict/sso-auth-bundle
evolvestudio/spam-protection
datacore/hub-sdk
develia/commons
cuci/prototurk-sdk
cuci/prototurk-sdk-symfony
develia/geo-bundle
dreamzy/livewire-charts
touchestate-sdk/php-sdk
ecotone/kafka
22h/doctrine-garbage-collection-bundle
agtp/agtp-php
agtp/mod-php
splash/sonata-admin
splash/metadata