Open-Awesome
CategoriesAlternativesStacksSelf-HostedExplore
Open-Awesome

© 2026 Open-Awesome. Curated for the developer elite.

TermsPrivacyAboutGitHubRSS
  1. Home
  2. PHP
  3. Brick Money

Brick Money

MITPHP0.14.0

A PHP library for immutable money and currency handling with exact arithmetic and explicit rounding control.

GitHubGitHub
1.9k stars118 forks0 contributors

What is Brick Money?

Brick\Money is a PHP library for handling monetary values with exact arithmetic, avoiding floating-point rounding errors. It provides immutable classes to represent money and currencies, ensuring precise calculations and giving developers explicit control over rounding behavior. The library is designed for production-grade financial applications where accuracy is critical.

Target Audience

PHP developers building financial applications, e-commerce systems, or any software requiring precise monetary calculations, such as payment processors, accounting software, or budgeting tools. It is particularly suited for projects where rounding errors could lead to financial discrepancies.

Value Proposition

Developers choose Brick\Money for its emphasis on immutability, precision, and explicit rounding control, which prevents silent financial calculation errors. Its unique selling points include support for advanced features like RationalMoney for fraction-based intermediate calculations, flexible currency conversion with exchange rate providers, and money allocation/splitting with various modes.

Overview

A money and currency library for PHP

Use Cases

Best For

  • Handling exact monetary calculations in PHP without floating-point rounding errors, such as in e-commerce or payment systems.
  • Implementing currency conversion with support for multiple exchange rate providers, including database-backed and cached rates.
  • Allocating or splitting money according to ratios with different allocation modes, useful for profit distribution or expense sharing.
  • Working with custom currencies beyond ISO 4217 standards, like cryptocurrencies or proprietary tokens.
  • Performing cash rounding for currencies with specific increment rules, such as Swiss Francs (CHF) with 5-cent steps.
  • Aggregating monies in different currencies into a MoneyBag for mixed-currency operations and conversions.

Not Ideal For

  • Projects requiring only simple price display without arithmetic operations, where lightweight alternatives suffice.
  • High-performance transactional systems where computational overhead from exact arithmetic is unacceptable without GMP/BCMath extensions.
  • Legacy codebases stuck on unsupported PHP versions (below 8.2) without upgrade paths.

Pros & Cons

Pros

Exact Arithmetic Precision

Based on brick/math, it avoids floating-point errors by performing exact calculations on monies of any size, crucial for financial accuracy.

Flexible Monetary Contexts

Supports contexts like CashContext for cash rounding and AutoContext for auto-scaling, allowing tailored handling for different use cases.

Advanced Allocation Features

Provides multiple allocation and splitting modes (e.g., FloorToFirst, Separate) for precise money distribution, useful in profit sharing or expense splitting.

Immutable and Thread-Safe

Money instances are immutable, preventing accidental modifications and ensuring safe concurrency in applications.

Cons

Performance Dependency on Extensions

Without GMP or BCMath extensions, calculations can be slower, potentially impacting high-throughput systems as noted in the requirements.

Pre-1.0 Breaking Changes

Being in 0.x versions, new release cycles introduce breaking changes, requiring careful version locking and upgrade planning.

Formatting Discrepancies for Large Values

Formatting uses NumberFormatter which converts to float, causing potential inaccuracies with very large monetary amounts, as admitted in the README.

Open Source Alternative To

Brick Money is an open-source alternative to the following products:

m
moneyphp/money

Frequently Asked Questions

Quick Stats

Stars1,919
Forks118
Contributors0
Open Issues4
Last commit10 days ago
CreatedSince 2015

Tags

#currency-converter#exchange-rates#money-handling#php-library#currency-conversion#money#iso-4217#currency#immutable#exact-arithmetic#php#financial#monetary-calculations

Built With

G
GMP
P
PDO
B
BCMath
P
PHP

Included in

PHP32.5k
Auto-fetched 19 hours ago

Related Projects

OmniPayOmniPay

A framework agnostic, multi-gateway payment processing library for PHP 5.6+

Stars6,058
Forks930
Last commit14 days ago
MoneyMoney

PHP implementation of Fowler's Money pattern.

Stars4,857
Forks444
Last commit17 days ago
ShopwareShopware

Shopware 6 is an open commerce platform based on Symfony Framework and Vue and supported by a worldwide community and more than 3.100 community extensions

Stars3,392
Forks1,192
Last commit17 hours ago
PayumPayum

PHP Payment processing library. It offers everything you need to work with payments: Credit card & offsite purchasing, subscriptions, payouts etc.

Stars1,924
Forks346
Last commit5 months ago
Community-curated · Updated weekly · 100% open source

Found a gem we're missing?

Open-Awesome is built by the community, for the community. Submit a project, suggest an awesome list, or help improve the catalog on GitHub.

Submit a projectStar on GitHub