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

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.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Monetization & Payments Features

    • Implement precise financial calculations (e.g., subscriptions, invoicing, tax calculations) without floating-point errors.
    • Enable multi-currency support for global applications (e.g., e-commerce, SaaS platforms).
    • Build features like split payments, currency conversion, or dynamic pricing tiers with confidence.
  • Roadmap Prioritization

    • Build vs. Buy: Avoid reinventing financial math logic (e.g., rounding, allocation, exchange rates). Leverage this package to accelerate development.
    • Scalability: Use the immutable Money object to ensure thread-safe operations in high-concurrency systems (e.g., payment processors).
    • Compliance: Align with financial regulations (e.g., exact decimal arithmetic for audits, tax reporting).
  • Use Cases

    • Marketplaces: Split fees/payouts across vendors with allocate() (e.g., 60/30/10 splits).
    • Crypto Integration: Support crypto-currencies (e.g., Bitcoin, Ethereum) via CryptoCurrencies class.
    • Localization: Format amounts in user-preferred locales (e.g., IntlLocalizedDecimalFormatter).
    • Legacy Migration: Gradually adopt the Money pattern via the Teller adapter for existing float-based systems.

When to Consider This Package

  • Adopt if:

    • Your app handles any financial data (even internally, e.g., pricing models, analytics).
    • You need exact arithmetic (e.g., 0.1 + 0.2 !== 0.3 in floats breaks your logic).
    • Your team uses Laravel/PHP and wants to avoid custom financial libraries.
    • You require multi-currency support with exchange rates (e.g., Swap or Exchanger integrations).
    • You’re building auditable systems (e.g., accounting, compliance tools).
  • Look elsewhere if:

    • You’re using non-PHP stacks (e.g., Python’s decimal.Decimal, Java’s BigDecimal).
    • Your use case is trivial (e.g., displaying pre-calculated prices without math operations).
    • You need real-time exchange rate APIs (this package provides the math, not live rates—pair with a service like ExchangeRate-API).
    • Your team lacks PHP 8.0+ (requires BCMath extension; alternatives like brianium/paragonie_number exist for older PHP).

How to Pitch It (Stakeholders)

For Executives:

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

  • Global payments (multi-currency, exchange rates).
  • Pricing engines (dynamic tiers, splits).
  • Compliance (exact decimal arithmetic for taxes/audits). No reinventing the wheel—just safer, faster financial logic."*

For Engineers:

*"This is the Fowler Money Pattern implemented in PHP, solving:

  • Floating-point hell: Uses strings/BCMath for exact arithmetic (e.g., Money::EUR(500)->add(Money::EUR(500)) === Money::EUR(1000)).
  • Multi-currency: Built-in ISO currencies + crypto support (e.g., Money::BTC(0.5)).
  • Exchange rates: Integrates with Swap or Exchanger for dynamic conversions.
  • Performance: Optimized for high-volume systems (e.g., payment processing). Tradeoff: Requires BCMath (enabled by default in PHP). Alternatives: If BCMath is blocked, we can explore gmp or brianium/paragonie_number as fallbacks. Next steps:
  1. Add to composer.json (composer require moneyphp/money).
  2. Replace floats with Money objects (e.g., Money::USD(1000) instead of 1000.00).
  3. Leverage allocate() for splits, Converter for exchanges, and IntlLocalizedDecimalFormatter for localization. ROI: Faster dev, fewer bugs, and future-proof financial logic."*
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.
calmfox/watch-sylius
damienfern/grpc-symfony-bundle
atoolo/index-bundle
atoolo/genai-bundle
coprotoai/laravel-ticket
davidjln/llm-carbon-bundle
cryonighter/valid-request-bundle
coolms/taxonomy-bundle
coolms/field-bundle
articulate-orm/symfony
aaix/laravel-tall-architect
ephoto/akeneo-connector
emmanuelballery/eb-plantumlbundle
emielburgman/symfony-visitor-beacon
emielburgman/symfony-visit-storage
emielburgman/symfony-security-headers
emielburgman/symfony-log-viewer
emarref/xdebug-bundle
emarref/pubnub-bundle
elriseio/finance-money-bundle