- How do I install worksome/exchange in a Laravel application?
- Install it with Composer using composer require worksome/exchange. Laravel auto-discovers the service provider, so no manual registration is normally needed. Publish the package config if you need to set the driver or provider credentials.
- How do I configure the exchange rate driver in worksome/exchange?
- Publish the config file, then choose the exchange-rate driver and any required credentials or endpoints. The driver abstraction lets you swap providers through configuration without changing application code. For Frankfurter, confirm the base URL points at the API version your driver expects, especially for self-hosted deployments.
- What are the breaking changes in worksome/exchange v3.0.0?
- Version 3.0.0 removes the getBaseCurrency, getRates, and getRetrievedAt methods in favor of the baseCurrency, rates, and retrievedAt properties. It also moves the Frankfurter driver to API v2, adds a parallel frankfurter_v2 driver, and casts the base currency to float. Missing a removed getter causes a fatal runtime error rather than a warning.
- How do I read baseCurrency, rates, and retrievedAt from the Rates object?
- Use $rates->baseCurrency, $rates->rates, and $rates->retrievedAt after receiving a Rates instance. The v3 object exposes these as public properties, so method syntax such as $rates->getRates() will fail. If you cache or serialize Rates payloads, review the float cast on baseCurrency because it can change the serialized shape.
- Does worksome/exchange cache exchange rates?
- The package is designed around fetching rates through a driver, and caching should be owned by your application or an explicit layer in front of provider calls. You control the cache key, TTL, and whether you persist the Rates object or just the rate map. Do not assume the package provides a complete cache policy for every driver.
- Should I use the frankfurter or frankfurter_v2 driver?
- The frankfurter driver now targets Frankfurter API v2, so self-hosted deployments must expose v2 and update FRANKFURTER_BASE_URL from the v1 path to the v2 path. A separate frankfurter_v2 driver was introduced as a parallel option before the default driver changed, so confirm which one your package version recommends. Standardize on one driver to avoid carrying two Frankfurter integrations.
- How do I migrate from worksome/exchange v2 to v3?
- Inventory every call to getBaseCurrency, getRates, and getRetrievedAt across app code, packages, and tests, then replace them with property access. Use grep plus static analysis such as PHPStan or Larastan, or a Rector rule, to produce a reviewable diff. Run the full test suite and check cached or serialized Rates payloads because v3 also changes the base currency to float.
- Can worksome/exchange handle rounding and accounting precision?
- No, worksome/exchange retrieves quoted exchange rates; it is not an accounting or ledger library. Rounding, precision policy, and rate-source auditability remain your responsibility. Treat the Rates object as infrastructure data and apply your own monetary rules before storing financial values.
- How do I test currency conversion with worksome/exchange?
- Because rates come through a driver abstraction and a Rates value object, you can bind a test driver or mock the provider in Laravel tests. Assert on baseCurrency, rates, and retrievedAt rather than on live network responses. Keep tests for conversion logic separate from tests that verify a real provider integration.
- What PHP and Laravel versions does worksome/exchange v3 support?
- Check the package composer.json for the exact PHP and Laravel constraints before upgrading, because v3 is a major release with runtime-breaking changes. The standard integration path is Composer plus Laravel auto-discovery, but your CI matrix should confirm the supported versions. Do not assume v2 constraints carry over unchanged.