Skip to content

Why Currency?

Handling money with PHP float values and ad-hoc number_format() calls breaks silently as soon as a project introduces multi-currency pricing, deposits, refunds, tax splits, or historical accounting reports.

Problem Raw PHP float & Custom Scripts ProcessWire Currency
Rounding drift (0.1 + 0.2) Binary floating-point inaccuracies accumulate across line items Integer minor units (Money) + exact DecimalMath (ext-bcmath), rejecting float in Money::fromMajor()
Splitting deposits or taxes Naive division drops or duplicates 1 cent Largest-remainder Money::allocate() guarantees array_sum($parts) === $amountMinor
Exchange rate sourcing Hardcoded multipliers or fragile cron scripts Built-in EcbProvider, TcmbProvider, ManualProvider, plus ExchangeRateProviderInterface and SyncExchangeRatesTask
Historical invoice accuracy Overwriting a rate breaks past order conversions Locked currency-rate-history snapshots queried by effectiveDate (findRateOnOrBefore, findCrossRateOnOrBefore)
Safe base currency changes Manual SQL updates risk corrupting sibling rates Atomic setBaseCurrency() under CurrencyWriteLock and Entries::saveMany() rebases every sibling rate safely
SSRF & cookie security Unpinned file_get_contents() and unsafe cookie names WireHttpTransport pins resolved public IPs (CURLOPT_RESOLVE, 5 MiB cap) and VisitorCurrencyResolver blocks reserved session/CSRF cookie names

Upper-layer modules including Payments, Forms, Packages, Commerce, and Charter depend on Currency for ISO 4217 validation, currencyOptions(), resolveAllowedCurrencies(), and minor-unit precision. Configuring currencies once in Setup -> Currencies keeps your entire ProcessWire stack aligned.

Next steps