florianv/swap
PHP 8.2+ currency exchange rate library with a single API over 30+ providers. Supports conversion, historical rates, PSR-16 caching, and provider fallback. Works with PSR-18 HTTP clients and PSR-17 factories for flexible integrations.
florianv/laravel-swap package further simplifies integration.Exchanger if needed. This aligns well with Laravel’s modularity and dependency injection patterns.Builder configuration) and works seamlessly with Laravel’s service container.config/app.php.symfony/cache or stash are common Laravel choices), which Laravel already supports natively.fastforex) may introduce latency or cost risks if not monitored. Fallback chains mitigate this but require proactive management.european_central_bank) offer limited currency pairs or update frequencies, which may not suit real-time applications.coin_layer), which may not meet all use cases.fastforex) or rely on free tiers with limitations?Swap\Builder as a singleton or bind it to an interface..env and provider settings in config/swap.php.file, redis, database) as PSR-16 caches.Http facade or Guzzle (via php-http/guzzle7-adapter) work out of the box.moneyphp/money for amount conversion.Builder in a single module (e.g., checkout).european_central_bank (free) for initial testing.fastforex (or another commercial provider) as the primary source with fallbacks.composer require florianv/swap symfony/http-client nyholm/psr7.php artisan vendor:publish --provider="Swap\ServiceProvider" (if using laravel-swap)..env (e.g., FASTFOREX_API_KEY) and config/swap.php.Mockery or Swap\Test\MockProvider).european_central_bank) in staging.fastforex free tier limits).florianv/swap and its dependencies (e.g., symfony/http-client) regularly.ChainException to identify which providers failed.fastforex paid plans start at $18/month).| Failure Scenario | Impact | Mitigation |
|---|---|---|
| Primary provider outage | No rates available | Fallback chain to secondary providers. |
| API key revoked/expired | Authentication failures | Automated alerts + key rotation. |
| Rate data stale | Inaccurate conversions | Short TTLs + manual refresh triggers. |
| Provider rate limits exceeded | Throttled requests | Implement retry logic with backoff. |
| Cache corruption | Stale rates served | Use cache invalidation events. |
swap.php config template with commented examples.fastforex vs. european_central_bank).1 EUR = ~1.08 USD).fastforex vs. european_central_bank).ChainException occurrences.How can I help you explore Laravel packages today?