florianv/laravel-swap
Laravel Swap lets you convert currencies and fetch exchange rates in Laravel apps. It wraps the Swap PHP library, supporting multiple rate providers, caching, and simple configuration for reliable currency conversion.
florianv/swap bump to ^4.6 pulls in Exchanger 2.11's provider fixes, so you inherit vendor maintenance rather than owning it.exchange_rates_api free plan is EUR-based. That is a product-level detail: it changes which pairs you get directly versus which you must derive via cross-rates, and it affects rounding error on display prices. Worth deciding deliberately rather than discovering in QA.Adopt when:
InvalidArgumentException when swap.cache, swap.http_client, or swap.request_factory are given non-class-name values, so misconfiguration surfaces at boot rather than as a silent wrong-rate at runtime.Look elsewhere or build when:
coin_layer provider transmits your API key over plain HTTP unless paid is set to true. Treat that as a security/compliance gate, not a config detail — it likely disqualifies that provider for production handling of any commercially sensitive traffic.If you are already on 2.4.x: upgrading to 2.5.0 is a minor-version bump with a genuine breaking edge — the Laravel 10 / Lumen support drop. If you're on Laravel 11+, upgrade. Then re-publish or diff config/swap.php: 2.5.0 corrects the documented option names per provider (APILayer services use api_key, not access_key), which means anyone who worked around the old names now has a now-incorrect workaround, and anyone who copied the old config may have been running against a silently ignored key. Budget a short verification pass per configured provider rather than assuming a no-op.
Executives: This is a small, MIT-licensed integration layer that lets us price and display in local currencies in days rather than a quarter. It reduces vendor risk: it supports multiple rate providers with automatic fallback, so a degraded or expensive rate source doesn't become an outage or an emergency migration — and this release broadens that fallback pool, including to a free central-bank source. Caching keeps third-party costs and latency predictable. The surface area is deliberately thin, so if our needs outgrow it — or if we move to a provider that settles FX for us — we replace a wrapper, not our domain code. The one material caveat is platform commitment: it now requires Laravel 11+, so this is only a candidate if we're current or upgrading anyway. Low cost, low lock-in, clear exit.
Engineering: It's a thin Laravel wrapper around the maintained florianv/swap library: auto-discovered service provider, facade, and a published config file covering provider selection, fallback ordering, and cache TTL. It is not a new FX engine — it standardizes how rates, caching, and fallback are wired into the container.
Changes in 2.5.0 that affect our integration plan:
florianv/swap ^4.6 / Exchanger 2.11. Pin it and let the provider-level fixes come with it.config/swap.php; per-provider option names were wrong for the APILayer services (access_key vs api_key). Remove any local workaround. Add a boot-time assertion in CI that our configured provider keys resolve, so a silently ignored key can't ship.swap.cache, swap.http_client, swap.request_factory now throw InvalidArgumentException. Good — wire our cache store and HTTP client by class name and let it fail loudly in CI.coin_layer sends the API key over HTTP unless paid is true. Don't enable it without that flag and a conscious decision.exchange_rates_api free plan is EUR-based — verify the pairs you actually need are direct, or accept cross-rate derivation and its rounding.Plan to add: provider credentials in config/env, sensible cache TTLs per environment, a fake or stubbed provider for deterministic tests, and — importantly — our own persistence of the rate applied at the moment of each transaction so audit and refunds never depend on a live API call. Watch rounding and minor-unit precision explicitly, and pin the underlying library. Adoption risk is low and reversible; treat the provider relationship and rate-accuracy guarantees as the real dependency to manage.
How can I help you explore Laravel packages today?