brick/money
Money and currency library
0.14.1
44M downloads/mo
#559 most downloaded on Packagist
brick/money
What this package is like to depend on
Last release 24 days ago
30 Jul 2026
Release timing varies
gaps range from 8 days to 5 months
Nearly every release is documented
notes for 41 of 42 stable releases
Nothing withdrawn
no release was ever pulled
9 years old
42 releases · first in 2017
11 releases in the last 12 months
see the full history below
Release timeline
42 releases · Oct 2017 to Jul 2026Releases
latest 42-
0.14.130 Jul 2026 -
0.14.014 Jul 2026Release notes
Open source →💥 Breaking changes
- deprecated class
ProviderChainhas been removed; useChainProviderinstead - deprecated method
MoneyBag::fromMonies()has been removed; useof()instead
📌 Compatibility
Release notes
Open source →💥 Breaking changes
- deprecated class
ProviderChainhas been removed; useChainProviderinstead - deprecated method
MoneyBag::fromMonies()has been removed; useof()instead
📌 Compatibility
- Compatibility with
brick/mathversion0.18(#129 by @delolmo)
- deprecated class
-
0.13.028 Mar 2026Release notes
Open source →💥 Breaking changes
MoneyBagcan no longer be instantiated withnew: its constructor is now private; useMoneyBag::zero()to create an empty instanceMoney::convertedTo()now defaults toDefaultContextinstead of$this's context- The following methods no longer accept
nullfor the$contextparameter:CurrencyConverter::convert()Money::of()Money::ofMinor()Money::zero()Money::convertedTo()
Money::allocate()signature has changed: replaceallocate(1, 2, 3)withallocate([1, 2, 3], AllocationMode::FloorToFirst)to keep the same behaviour as beforeMoney::allocateWithRemainder()has been removed: replaceallocateWithRemainder(1, 2, 3)withallocate([1, 2, 3], AllocationMode::BlockSeparate)to keep the same behaviour as beforeMoney::split()signature has changed: replacesplit(3)withsplit(3, SplitMode::ToFirst)to keep the same behaviour as beforeMoney::splitWithRemainder()has been removed: replacesplitWithRemainder(3)withsplit(3, SplitMode::Separate)to keep the same behaviour as before- The following methods now throw an exception when used on a
MoneywithAutoContext:quotient()remainder()quotientAndRemainder()allocate()split()
MoneyBagno longer retains zero-balance currencies afterplus()/minus()operationsExchangeRateProvider::getExchangeRate()signature has changed: it now acceptsCurrencyinstances, and returnsBigNumber|nullCurrencyConversionExceptionhas been renamed toExchangeRateException, withExchangeRateProviderExceptionandExchangeRateNotFoundExceptionsubclassesPdoProvider::setParameters()has been removed, use dimension bindings insteadPdoProviderconstructor is now private, usePdoProvider::builder()->...->build()to create an instancePdoProviderConfigurationhas been removed, usePdoProvider::builder()insteadCurrencyConverter::convert()signature has changed: parameter$dimensionsnow comes before$contextCachedProvider::invalidate()has been removed, pass a PSR-16 cache implementation to the constructor if you need to invalidate the cacheMoneyComparatorconstructor now requires aComparisonModeinstance, explicitly pass an instance ofPairwiseModeto keep the same behaviour as beforeConfigurableProvideris now immutable:setExchangeRate()has been removed, useConfigurableProvider::builder()->addExchangeRate()->build()instead- The following methods now throw an exception when the exchange rate is negative or zero:
Money::convertedTo()RationalMoney::convertedTo()CurrencyConverter::convert()CurrencyConverter::convertToRational()
- The following methods now throw when performing same-currency operations with a rate different from
1:Money::convertedTo()RationalMoney::convertedTo()
- Constructors and factory methods of library-internal exceptions are now
@internal Contextmethods are now@internal: userland code should only rely on constructors- Interfaces
Context,Monetary, andMoneyExceptionare now sealed: userland implementations are no longer supported - Built-in
ExchangeRateProviderimplementations now consistently return1for same-currency pairs
Deprecated methods removed:
AbstractMoney::to()has been removed, usetoContext()insteadAbstractMoney::isAmountAndCurrencyEqualTo()has been removed, useisSameValueAs()insteadMoney::total()has been removed, usesum()insteadMoney::getUnscaledAmount()has been removed, usegetAmount()->getUnscaledValue()insteadRationalMoney::simplified()has been removed,RationalMoneyis always in its simplest form nowMoneyBag::add()has been removed, useplus()instead, which returns a new instanceMoneyBag::subtract()has been removed, useminus()instead, which returns a new instance
The following breaking changes only affect you if you're using named arguments:
Currency::ofNumericCode()now uses$numericCodeas the parameter nameIsoCurrencyProvider::getCurrencyByNumericCode()now uses$numericCodeas the parameter nameMoneyBag::plus()andminus()now use$thatas the parameter name
⚠️ Deprecations
- Method
MoneyBag::fromMonies()is deprecated, useof()instead - Class
ProviderChainis deprecated, useChainProviderinstead
✨ New features
- Support for custom dimensions (date, rate type, ...) in
ExchangeRateProvider,CurrencyConverterandMoneyComparator - Support for
Money,RationalMoney, andMoneyBaginMoneyComparator - Support for multiple comparison modes in
MoneyComparator - New
Money::allocate()API with five algorithms, exposed through the newAllocationModeenum:FloorToFirst(this is the implementationallocate()used previously)FloorToLargestRatioFloorToLargestRemainderFloorSeparateBlockSeparate(this is the implementationallocateWithRemainder()used previously)
- New
Money::split()API with two algorithms, exposed through the newSplitModeenum:ToFirst(this is the implementationsplit()used previously)Separate(this is the implementationsplitWithRemainder()used previously)
MoneyMismatchExceptionnow has explicitCurrencyMismatchExceptionandContextMismatchExceptionsubclasses- New exception:
MoneyFormatException, thrown byMoneyFormatter::format() - New methods in
MoneyBag:isZero(),multipliedBy(),dividedBy(),negated(),isEqualTo(),of()(replacesfromMonies()) - New methods in
RationalMoney:min(),max(),sum() - Support for custom PSR-16 cache implementations in
CachedProvider - New exchange rate provider:
ChainProvider(replacesProviderChain) - Support for numeric currency codes in
PdoProvider
Release notes
Open source →💥 Breaking changes
MoneyBagcan no longer be instantiated withnew: its constructor is now private; useMoneyBag::zero()to create an empty instanceMoney::convertedTo()now defaults toDefaultContextinstead of$this's context- The following methods no longer accept
nullfor the$contextparameter:CurrencyConverter::convert()Money::of()Money::ofMinor()Money::zero()Money::convertedTo()
Money::allocate()signature has changed: replaceallocate(1, 2, 3)withallocate([1, 2, 3], AllocationMode::FloorToFirst)to keep the same behaviour as beforeMoney::allocateWithRemainder()has been removed: replaceallocateWithRemainder(1, 2, 3)withallocate([1, 2, 3], AllocationMode::BlockSeparate)to keep the same behaviour as beforeMoney::split()signature has changed: replacesplit(3)withsplit(3, SplitMode::ToFirst)to keep the same behaviour as beforeMoney::splitWithRemainder()has been removed: replacesplitWithRemainder(3)withsplit(3, SplitMode::Separate)to keep the same behaviour as before- The following methods now throw an exception when used on a
MoneywithAutoContext:quotient()remainder()quotientAndRemainder()allocate()split()
MoneyBagno longer retains zero-balance currencies afterplus()/minus()operationsExchangeRateProvider::getExchangeRate()signature has changed: it now acceptsCurrencyinstances, and returnsBigNumber|nullCurrencyConversionExceptionhas been renamed toExchangeRateException, withExchangeRateProviderExceptionandExchangeRateNotFoundExceptionsubclassesPdoProvider::setParameters()has been removed, use dimension bindings insteadPdoProviderconstructor is now private, usePdoProvider::builder()->...->build()to create an instancePdoProviderConfigurationhas been removed, usePdoProvider::builder()insteadCurrencyConverter::convert()signature has changed: parameter$dimensionsnow comes before$contextCachedProvider::invalidate()has been removed, pass a PSR-16 cache implementation to the constructor if you need to invalidate the cacheMoneyComparatorconstructor now requires aComparisonModeinstance, explicitly pass an instance ofPairwiseModeto keep the same behaviour as beforeConfigurableProvideris now immutable:setExchangeRate()has been removed, useConfigurableProvider::builder()->addExchangeRate()->build()instead- The following methods now throw an exception when the exchange rate is negative or zero:
Money::convertedTo()RationalMoney::convertedTo()CurrencyConverter::convert()CurrencyConverter::convertToRational()
- The following methods now throw when performing same-currency operations with a rate different from
1:Money::convertedTo()RationalMoney::convertedTo()
- Constructors and factory methods of library-internal exceptions are now
@internal Contextmethods are now@internal: userland code should only rely on constructors- Interfaces
Context,Monetary, andMoneyExceptionare now sealed: userland implementations are no longer supported - Built-in
ExchangeRateProviderimplementations now consistently return1for same-currency pairs
Deprecated methods removed:
AbstractMoney::to()has been removed, usetoContext()insteadAbstractMoney::isAmountAndCurrencyEqualTo()has been removed, useisSameValueAs()insteadMoney::total()has been removed, usesum()insteadMoney::getUnscaledAmount()has been removed, usegetAmount()->getUnscaledValue()insteadRationalMoney::simplified()has been removed,RationalMoneyis always in its simplest form nowMoneyBag::add()has been removed, useplus()instead, which returns a new instanceMoneyBag::subtract()has been removed, useminus()instead, which returns a new instance
The following breaking changes only affect you if you're using named arguments:
Currency::ofNumericCode()now uses$numericCodeas the parameter nameIsoCurrencyProvider::getCurrencyByNumericCode()now uses$numericCodeas the parameter nameMoneyBag::plus()andminus()now use$thatas the parameter name
⚠️ Deprecations
- Method
MoneyBag::fromMonies()is deprecated, useof()instead - Class
ProviderChainis deprecated, useChainProviderinstead
✨ New features
- Support for custom dimensions (date, rate type, ...) in
ExchangeRateProvider,CurrencyConverterandMoneyComparator - Support for
Money,RationalMoney, andMoneyBaginMoneyComparator - Support for multiple comparison modes in
MoneyComparator - New
Money::allocate()API with five algorithms, exposed through the newAllocationModeenum:FloorToFirst(this is the implementationallocate()used previously)FloorToLargestRatioFloorToLargestRemainderFloorSeparateBlockSeparate(this is the implementationallocateWithRemainder()used previously)
- New
Money::split()API with two algorithms, exposed through the newSplitModeenum:ToFirst(this is the implementationsplit()used previously)Separate(this is the implementationsplitWithRemainder()used previously)
MoneyMismatchExceptionnow has explicitCurrencyMismatchExceptionandContextMismatchExceptionsubclasses- New exception:
MoneyFormatException, thrown byMoneyFormatter::format() - New methods in
MoneyBag:isZero(),multipliedBy(),dividedBy(),negated(),isEqualTo(),of()(replacesfromMonies()) - New methods in
RationalMoney:min(),max(),sum() - Support for custom PSR-16 cache implementations in
CachedProvider - New exchange rate provider:
ChainProvider(replacesProviderChain) - Support for numeric currency codes in
PdoProvider
-
0.12.323 Mar 2026Release notes
Open source →⚠️ Deprecations
- Method
AbstractMoney::isAmountAndCurrencyEqualTo()is deprecated, useisSameValueAs()instead
🔄 Reverted deprecations
- The deprecation notice when calling
AbstractMoney::isEqualTo()with a money in a different currency (introduced in 0.12.1) has been removed; this method will continue to throw aMoneyMismatchException
✨ New features
- New method:
AbstractMoney::isSameValueAs()(replacesisAmountAndCurrencyEqualTo())
Release notes
Open source →⚠️ Deprecations
- Method
AbstractMoney::isAmountAndCurrencyEqualTo()is deprecated, useisSameValueAs()instead
🔄 Reverted deprecations
- The deprecation notice when calling
AbstractMoney::isEqualTo()with a money in a different currency (introduced in 0.12.1) has been removed; this method will continue to throw aMoneyMismatchException
✨ New features
- New method:
AbstractMoney::isSameValueAs()(replacesisAmountAndCurrencyEqualTo())
- Method
-
0.12.219 Mar 2026Release notes
Open source →✨ New features
Money::allocate()&allocateWithRemainder()now acceptBigNumber|int|stringand support decimal & rational ratios- New method:
Money::remainder() - Methods
abs()andnegated()are now available onAbstractMoney
📌 Compatibility
- Compatibility with
brick/mathversion0.17
Release notes
Open source →✨ New features
Money::allocate()&allocateWithRemainder()now acceptBigNumber|int|stringand support decimal & rational ratios- New method:
Money::remainder() - Methods
abs()andnegated()are now available onAbstractMoney
📌 Compatibility
- Compatibility with
brick/mathversion0.17
-
0.12.111 Mar 2026Release notes
Open source →⚠️ Deprecations
- Calling
AbstractMoney::isEqualTo()with a money in a different currency now triggers a deprecation notice;in a future version, it will returnNote: this deprecation has been reverted in versionfalseinstead of throwing aMoneyMismatchException. UsecompareTo() === 0if you need the throwing behaviour.0.12.3.
📌 Compatibility
- Compatibility with
brick/mathversion0.16
- Calling
-
0.12.003 Mar 2026Release notes
Open source →💥 Breaking changes
- Calling the following methods with floating-point values is no longer supported, explicitly cast floats to string
(string) $floatto get the same behaviour as before (brick/math#105):Money::of(),ofMinor(),plus(),minus(),multipliedBy(),dividedBy(),quotient(),quotientAndRemainder(),convertedTo()RationalMoney::of(),plus(),minus(),multipliedBy(),dividedBy()AbstractMoney::compareTo(),isEqualTo(),isLessThan(),isLessThanOrEqualTo(),isGreaterThan(),isGreaterThanOrEqualTo()ConfigurableProvider::setExchangeRate()
- Calling
Currency::of()with a numeric code is no longer supported, useCurrency::ofNumericCode()instead (#104) - Calling the following methods with a numeric currency code is no longer supported, use a
Currencyinstance fromCurrency::ofNumericCode()instead (#104):Money::of()Money::ofMinor()Money::zero()Money::convertedTo()RationalMoney::of()CurrencyConverter::convert()CurrencyConverter::convertToRational()IsoCurrencyProvider::getCurrency()
RationalMoneyis now always simplified to lowest terms:USD 25/100is automatically simplified toUSD 1/4Currency::$numericCodeis now nullablePdoProviderConfigurationnow has a private constructor, use a factory method instead- Internal method
Money::create()is nowprotected
Class name case changes:
ISOCurrencyProviderhas been renamed toIsoCurrencyProviderPDOProviderhas been renamed toPdoProviderPDOProviderConfigurationhas been renamed toPdoProviderConfiguration
Deprecated methods removed:
Currency::is()has been removed, useCurrency::isEqualTo()insteadMoneyBag::getAmount()has been removed, useMoneyBag::getMoney()->getAmount()insteadMoney::formatTo()has been removed, useMoney::formatToLocale()insteadMoney::formatWith()has been removed, useMoneyNumberFormatter::format()instead
⚠️ Deprecations
- Method
RationalMoney::simplified()is deprecated, as it is now a no-op - Method
Money::getUnscaledAmount()is deprecated, usegetAmount()->getUnscaledValue()instead - Method
Money::total()is deprecated, usesum()instead - Method
AbstractMoney::to()is deprecated, usetoContext()instead - Passing
nullto the$contextparameter of the following methods is deprecated, use named arguments if you need to skip$context:CurrencyConverter::convert()Money::of()Money::ofMinor()Money::zero()
- Passing
nullto the$contextparameter ofMoney::convertedTo()is deprecated, use an explicitContextinstance; the default will change toDefaultContextin a future version - Instantiating a
MoneyBagwithnewis deprecated, useMoneyBag::zero()orMoneyBag::fromMonies()instead - Method
MoneyBag::add()is deprecated, useplus()instead, which returns a new instance - Method
MoneyBag::subtract()is deprecated, useminus()instead, which returns a new instance
📌 Compatibility
- brick/money now requires
brick/math:~0.15
👌 Improvements
- All
InvalidArgumentExceptionthrown now implementMoneyException - More exceptions have been documented
CashContext::applyTo()now performs step ⟷ scale validation
✨ New features
- New method:
AbstractMoney::toRational() - New method:
Money::sum()(replacestotal()) - New method:
RationalMoney::convertedTo() - New method:
RationalMoney::abs() - New method:
RationalMoney::negated() - New
MoneyBagimmutable API:MoneyBag::zero()MoneyBag::fromMonies()MoneyBag::plus()MoneyBag::minus()
- New exception:
ContextExceptionthrown when a context cannot be applied - New
PDOProviderConfigurationfactory methods:forCurrencyPair()forFixedSourceCurrency()forFixedTargetCurrency()
MoneyBagnow implementsJsonSerializable
Release notes
Open source →💥 Breaking changes
- Calling the following methods with floating-point values is no longer supported, explicitly cast floats to string
(string) $floatto get the same behaviour as before (brick/math#105):Money::of(),ofMinor(),plus(),minus(),multipliedBy(),dividedBy(),quotient(),quotientAndRemainder(),convertedTo()RationalMoney::of(),plus(),minus(),multipliedBy(),dividedBy()AbstractMoney::compareTo(),isEqualTo(),isLessThan(),isLessThanOrEqualTo(),isGreaterThan(),isGreaterThanOrEqualTo()ConfigurableProvider::setExchangeRate()
- Calling
Currency::of()with a numeric code is no longer supported, useCurrency::ofNumericCode()instead (#104) - Calling the following methods with a numeric currency code is no longer supported, use a
Currencyinstance fromCurrency::ofNumericCode()instead (#104):Money::of()Money::ofMinor()Money::zero()Money::convertedTo()RationalMoney::of()CurrencyConverter::convert()CurrencyConverter::convertToRational()IsoCurrencyProvider::getCurrency()
RationalMoneyis now always simplified to lowest terms:USD 25/100is automatically simplified toUSD 1/4Currency::$numericCodeis now nullablePdoProviderConfigurationnow has a private constructor, use a factory method instead- Internal method
Money::create()is nowprotected
Class name case changes:
ISOCurrencyProviderhas been renamed toIsoCurrencyProviderPDOProviderhas been renamed toPdoProviderPDOProviderConfigurationhas been renamed toPdoProviderConfiguration
Deprecated methods removed:
Currency::is()has been removed, useCurrency::isEqualTo()insteadMoneyBag::getAmount()has been removed, useMoneyBag::getMoney()->getAmount()insteadMoney::formatTo()has been removed, useMoney::formatToLocale()insteadMoney::formatWith()has been removed, useMoneyNumberFormatter::format()instead
⚠️ Deprecations
- Method
RationalMoney::simplified()is deprecated, as it is now a no-op - Method
Money::getUnscaledAmount()is deprecated, usegetAmount()->getUnscaledValue()instead - Method
Money::total()is deprecated, usesum()instead - Method
AbstractMoney::to()is deprecated, usetoContext()instead - Passing
nullto the$contextparameter of the following methods is deprecated, use named arguments if you need to skip$context:CurrencyConverter::convert()Money::of()Money::ofMinor()Money::zero()
- Passing
nullto the$contextparameter ofMoney::convertedTo()is deprecated, use an explicitContextinstance; the default will change toDefaultContextin a future version - Instantiating a
MoneyBagwithnewis deprecated, useMoneyBag::zero()orMoneyBag::fromMonies()instead - Method
MoneyBag::add()is deprecated, useplus()instead, which returns a new instance - Method
MoneyBag::subtract()is deprecated, useminus()instead, which returns a new instance
📌 Compatibility
- brick/money now requires
brick/math:~0.15
👌 Improvements
- All
InvalidArgumentExceptionthrown now implementMoneyException - More exceptions have been documented
CashContext::applyTo()now performs step ⟷ scale validation
✨ New features
- New method:
AbstractMoney::toRational() - New method:
Money::sum()(replacestotal()) - New method:
RationalMoney::convertedTo() - New method:
RationalMoney::abs() - New method:
RationalMoney::negated() - New
MoneyBagimmutable API:MoneyBag::zero()MoneyBag::fromMonies()MoneyBag::plus()MoneyBag::minus()
- New exception:
ContextExceptionthrown when a context cannot be applied - New
PDOProviderConfigurationfactory methods:forCurrencyPair()forFixedSourceCurrency()forFixedTargetCurrency()
MoneyBagnow implementsJsonSerializable
- Calling the following methods with floating-point values is no longer supported, explicitly cast floats to string
-
0.11.202 Mar 2026Release notes
Open source →⚠️ Deprecations
Money::create()is now marked as@internal, and will be madeprotectedin version0.12
Release notes
Open source →⚠️ Deprecations
Money::create()is now marked as@internal, and will be madeprotectedin version0.12
-
0.11.112 Feb 2026Release notes
Open source →⚠️ Deprecations
- Added explicit
trigger_deprecation()calls to methods that were already marked as@deprecated, so deprecation notices are now emitted at runtime
📌 Compatibility
- Restricted compatibility to
brick/math:~0.14.4
👌 Improvements
- Fixed calls to deprecated brick/math and brick/money APIs
Release notes
Open source →⚠️ Deprecations
- Added explicit
trigger_deprecation()calls to methods that were already marked as@deprecated, so deprecation notices are now emitted at runtime
📌 Compatibility
- Restricted compatibility to
brick/math:~0.14.4
👌 Improvements
- Fixed calls to deprecated brick/math and brick/money APIs
- Added explicit
-
0.11.022 Jan 2026Release notes
Open source →💥 Breaking changes
- Minimum PHP version is now 8.2
- The following classes are now
final:CurrencyConversionExceptionMoneyMismatchExceptionUnknownCurrencyException
CustomContextnow validates the step and will throw an exception if an invalid step is given- Interface
MoneyContainerhas been removed (replaced withMonetary) - Method
AbstractMoney::getAmounts()has been removed (replaced withgetMonies()) - Method
MoneyBag::getAmounts()has been removed (replaced withgetMonies()) CurrencyConverter::convert()andconvertToRational()now accept aMonetaryinstance (which still includesMoney,RationalMoneyandMoneyBag)MoneyBag::add()andsubtract()now accept aMonetaryinstance (which still includesMoney,RationalMoneyandMoneyBag)
⚠️ Deprecations
- Calling
Currency::of()with a numeric code is deprecated, useCurrency::ofNumericCode()instead - Calling
ISOCurrencyProvider::getCurrency()with a numeric code is deprecated, usegetCurrencyByNumericCode()instead - Calling
CurrencyConverter::convert()orconvertToRational()with a numeric currency code is deprecated, use aCurrencyinstance instead - Calling
Money::of(),ofMinor(),zero()orconvertedTo()with a numeric currency code is deprecated, use aCurrencyinstance instead - Calling
RationalMoney::of()with a numeric currency code is deprecated, use aCurrencyinstance instead MoneyBag::getAmount()is deprecated, usegetMoney()insteadMoney::formatTo()is deprecated, useMoney::formatToLocale()insteadMoney::formatWith()is deprecated, useMoneyNumberFormatter::format()insteadCurrency::is()is deprecated, useCurrency::isEqualTo()instead
Important
The convenience of passing a currency by ISO numeric code in addition to alphabetic code has been deprecated, leaving only alphabetic-code lookup in generic APIs. For example,
Money::of()will acceptCurrency|stringin the future, instead ofCurrency|string|inttoday.
This makes explicit the separation between retrieval by alphabetic code, which has strong backwards compatibility guarantees, and retrieval by numeric code, which may change in minor versions due to ISO reassignments.
This will require users to explicitly obtain a currency throughCurrency::ofNumericCode(), which is documented as not being covered by the same BC guarantees.✨ New features
- Support for historical currencies in
Money::of(),Currency::of(), etc. (#104 by @survik1) - New enum:
CurrencyType - New methods:
Currency::getCurrencyType()returns the type of the currencyCurrency::ofNumericCode()returns a currency by its numeric ISO 4217 codeCurrency::isEqualTo()compares two currencies for equality (replacesis())ISOCurrencyProvider::getCurrencyByNumericCode()returns a currency by its numeric codeISOCurrencyProvider::getHistoricalCurrenciesForCountry()returns historical currencies for a countryMoneyBag::getMoney()returns the contained amount in a given currency (replacesgetAmount())MoneyBag::getMonies()returns the contained monies (replacesgetAmounts())Money::formatToLocale()formats the amount to a locale (replacesformatTo()) (#105 by @mklepaczewski)RationalMoney::zero()returns a zeroRationalMoneyin a given currency
- New interfaces:
Monetary(replacesMoneyContainer)MoneyFormatterformats a givenMoneyobject (#105 by @mklepaczewski)
- New classes:
MoneyLocaleFormatterformats a givenMoneyobject to a locale (#105 by @mklepaczewski)MoneyNumberFormatterformats a givenMoneyobject using aNumberFormatterinstance (#105 by @mklepaczewski)
Release notes
Open source →💥 Breaking changes
- Minimum PHP version is now 8.2
- The following classes are now
final:CurrencyConversionExceptionMoneyMismatchExceptionUnknownCurrencyException
CustomContextnow validates the step and will throw an exception if an invalid step is given- Interface
MoneyContainerhas been removed (replaced withMonetary) - Method
AbstractMoney::getAmounts()has been removed (replaced withgetMonies()) - Method
MoneyBag::getAmounts()has been removed (replaced withgetMonies()) CurrencyConverter::convert()andconvertToRational()now accept aMonetaryinstance (which still includesMoney,RationalMoneyandMoneyBag)MoneyBag::add()andsubtract()now accept aMonetaryinstance (which still includesMoney,RationalMoneyandMoneyBag)
⚠️ Deprecations
- Calling
Currency::of()with a numeric code is deprecated, useCurrency::ofNumericCode()instead - Calling
ISOCurrencyProvider::getCurrency()with a numeric code is deprecated, usegetCurrencyByNumericCode()instead - Calling
CurrencyConverter::convert()orconvertToRational()with a numeric currency code is deprecated, use aCurrencyinstance instead - Calling
Money::of(),ofMinor(),zero()orconvertedTo()with a numeric currency code is deprecated, use aCurrencyinstance instead - Calling
RationalMoney::of()with a numeric currency code is deprecated, use aCurrencyinstance instead MoneyBag::getAmount()is deprecated, usegetMoney()insteadMoney::formatTo()is deprecated, useMoney::formatToLocale()insteadMoney::formatWith()is deprecated, useMoneyNumberFormatter::format()insteadCurrency::is()is deprecated, useCurrency::isEqualTo()instead
[!IMPORTANT] The convenience of passing a currency by ISO numeric code in addition to alphabetic code has been deprecated, leaving only alphabetic-code lookup in generic APIs. For example,
Money::of()will acceptCurrency|stringin the future, instead ofCurrency|string|inttoday. This makes explicit the separation between retrieval by alphabetic code, which has strong backwards compatibility guarantees, and retrieval by numeric code, which may change in minor versions due to ISO reassignments. This will require users to explicitly obtain a currency throughCurrency::ofNumericCode(), which is documented as not being covered by the same BC guarantees.✨ New features
- Support for historical currencies in
Money::of(),Currency::of(), etc. (#104 by @survik1) - New enum:
CurrencyType - New methods:
Currency::getCurrencyType()returns the type of the currencyCurrency::ofNumericCode()returns a currency by its numeric ISO 4217 codeCurrency::isEqualTo()compares two currencies for equality (replacesis())ISOCurrencyProvider::getCurrencyByNumericCode()returns a currency by its numeric codeISOCurrencyProvider::getHistoricalCurrenciesForCountry()returns historical currencies for a countryMoneyBag::getMoney()returns the contained amount in a given currency (replacesgetAmount())MoneyBag::getMonies()returns the contained monies (replacesgetAmounts())Money::formatToLocale()formats the amount to a locale (replacesformatTo()) (#105 by @mklepaczewski)RationalMoney::zero()returns a zeroRationalMoneyin a given currency
- New interfaces:
Monetary(replacesMoneyContainer)MoneyFormatterformats a givenMoneyobject (#105 by @mklepaczewski)
- New classes:
MoneyLocaleFormatterformats a givenMoneyobject to a locale (#105 by @mklepaczewski)MoneyNumberFormatterformats a givenMoneyobject using aNumberFormatterinstance (#105 by @mklepaczewski)
👌 Improvements
MoneyExceptionnow extendsRuntimeExceptioninstead ofException
📝 Documentation
- Backward compatibility promise notes for currency updates
-
0.10.303 Sep 2025Release notes
Open source →👌 Improvements
- Compatibility with
brick/mathversion0.14(#101 by @markwalet)
- Compatibility with
-
0.10.205 Aug 2025Release notes
Open source →✨ New features
- Add possibility to pass previous exception in
CurrencyConversionException(#99 by @arokettu)
- Add possibility to pass previous exception in
-
0.10.105 Mar 2025Release notes
Open source →👌 Improvements
- Compatibility with
brick/mathversion0.13(#96 by @ekvedaras)
- Compatibility with
-
0.10.012 Oct 2024Release notes
Open source →💥 ISO currency changes
ZWG(Zimbabwe Gold) has been addedZWL(Zimbabwean Dollar) has been removedSLL(Sierra Leonean Leone) has been removed- The currency of Zimbabwe (
ZW) has been changed toZWG(Zimbabwe Gold) - The
SLLcurrency has been removed from Sierra Leone (SL), which only hasSLEnow
-
0.9.026 Nov 2023Release notes
Open source →💥 Breaking changes
- Minimum PHP version is now 8.1
PDOProviderConfigurationno longer has getters, its properties arepublic readonlyRoundingModefrombrick/mathis now an enum, so:- all methods accepting an
introunding mode now accept aRoundingModeinstance instead - this should be transparent to your application, as you'll be using the same constants such as
RoundingMode::UP
- all methods accepting an
-
0.8.123 Sep 2023Release notes
Open source → -
0.8.015 Jan 2023Release notes
Open source →💥 Breaking changes
- Minimum PHP version is now 8.0
- Due to Croatia's adoption of the Euro on January 1st, 2023:
- the
HRKcurrency (Kuna) has been removed from the ISO currency provider - the
HRcountry (Croatia) is now mapped toEUR(Euro)
- the
PDOProviderConfigurationnow has a proper constructor, and its properties are no longer publicPDOProviderConfigurationnow throws exceptions in the constructor when configuration is invalid- All documented union types are now strongly typed:
- If you have a custom
ExchangeRateProviderimplementation, you will need to update yourgetExchangeRate()method signature - If you were passing
Stringableobjects toof()or any of the methods internally callingof(), and havestrict_typesenabled, you will need to explicitly cast these objects tostringfirst
- If you have a custom
-
0.7.115 Jan 2023 -
0.7.005 Oct 2022Release notes
Open source →💥 Breaking changes
- JSON extension is now required for PHP 7.4 (always available with PHP >= 8.0)
AbstractMoneyis now officially sealed, extending it yourself is not supported
✨ New features
MoneyandRationalMoneynow implementJsonSerializable
-
0.6.001 Aug 2022Release notes
Open source →💥 Breaking changes
- Minimum PHP version is now 7.4
AbstractMoney::getAmount()now has a return typeCurrencyConverter's constructor does not accept a default$contextanymoreCurrencyConverter::convert()now requires the$contextpreviously accepted by the constructor as third parameterMoney::allocateWithRemainder()now refuses to allocate a portion of the amount that cannot be spread over all ratios, and instead adds that amount to the remainder (#55)Money::splitWithRemainder()now behaves likeallocateWithRemainder()
✨ New ISO currencies
SLE(Leone) in Sierra Leone (SL)
👌 Improvements
- Compatibility with
brick/mathversion0.10
-
0.5.310 Oct 2021Nothing published for this version
-
0.5.203 Apr 2021Release notes
Open source →✨ New methods
Money::allocateWithRemainder()Money::splitWithRemainder()
These methods perform like their
allocate()andsplit()counterparts, but append the remainder at the end of the returned array instead of spreading it over the first monies.Thanks @NCatalani!
-
0.5.110 Feb 2021Release notes
Open source →👌 Improvement
BaseCurrencyProvidernow always returns aBigNumberfor convenience (#37). This is useful if you're usingBaseCurrencyProvideron its own, not just inCurrencyConverter.Thanks @rdarcy1!
-
0.5.019 Aug 2020Release notes
Open source →👌 Improvements
- compatibility with
brick/mathversion0.9
⚠️ Caution
When using
brick/mathversion0.9, theMoneyfactory methods such asof()andofMinor()now accept decimal numbers in the form.123and123., and do not throw an exception anymore in this case. - compatibility with
-
0.4.531 May 2020Release notes
Open source →🐛 Bug fix
MoneyBag::getAmount(),add()andsubtract()would throw an exception when using a custom currency (#25). -
0.4.423 Jan 2020Release notes
Open source →✨ New method
AbstractMoney::isAmountAndCurrencyEqualTo()compares a money to another. (#17)This method is different from
isEqualTo()in 2 aspects:- it only accepts another money, not a raw number;
- it returns
falseif the money is in another currency, instead of throwing an exception.
-
0.4.309 Jan 2020Release notes
Open source →🛠 Improvements
MoneyBag::getAmount()now accepts an ISO numeric currency code as well
✨ New methods
CurrencyConverter::convertToRational()converts to aRationalMoney(#22)
-
0.4.204 Jul 2019Release notes
Open source →Performance improvement when calling
Money::formatTo()many times for the same locale. -
0.4.117 Oct 2018 -
0.4.009 Oct 2018Release notes
Open source →Breaking Changes
- Deprecated method
BigRational::toMoney()has been removed, useBigRational::to()instead; BigRational::__toString()now always outputs the amount in non-simplified rational form.
New methods
BigRational::simplified()returns a copy of the money with the amount simplified.
- Deprecated method
-
0.3.412 Sep 2018 -
0.3.322 Aug 2018 -
0.3.220 Aug 2018Release notes
Open source →Money::formatTo()can now format the amount as a whole number:formatTo(string $locale, bool $allowWholeNumber = false) : stringBy default,
formatTo()always outputs all the fraction digits:Money::of('23.5', 'USD')->formatTo('en_US'); // $23.50 Money::of(23, 'USD')->formatTo('en_US'); // $23.00But can now be allowed to return the whole number by passing
trueas a second argument:Money::of('23.5', 'USD')->formatTo('en_US', true); // $23.50 Money::of(23, 'USD')->formatTo('en_US', true); // $23Note that this version now requires
brick/mathversion0.7.3. This is not a BC break. If you've locked your composer.json to an earlier version, you will just not be able to installbrick/moneyversion0.3.2. -
0.3.104 Aug 2018 -
0.3.026 Jul 2018Release notes
Open source →New methods:
CurrencyConversionException::getSourceCurrencyCode()CurrencyConversionException::getTargetCurrencyCode()
This allows to programmatically get the failing currency pair when an exchange rate is not available.
Breaking change:
CurrencyConversionExceptionconstructor signature changed
Although this is technically a breaking change and requires a version bump, your code is unlikely to be affected, unless you're creating
CurrencyConversionExceptioninstances manually (you shouldn't). -
0.2.410 Jan 2018 -
0.2.301 Dec 2017 -
0.2.220 Nov 2017 -
0.2.105 Nov 2017 -
0.2.002 Oct 2017Release notes
Open source →- Minimum requirement is now PHP 7.1
BigRational::toMoney()has been deprecated; useto()instead. This is the result of a factorization of a common feature in Money and RationalMoney.
-
0.1.108 Dec 2017Release notes
Open source →Backports from 0.2.x:
CustomContext::getScale()Money::formatTo()now always respects the scale of the Money- Bug fix:
Money::allocate()incorrectly allocated negative monies
-
0.1.002 Oct 2017