- Can I install redcode/currency-rate-bundle in a Laravel application?
- Not practically. It is a Symfony2 bundle built around a DependencyInjection extension, services.xml wiring and an AppKernel-registered bundle class, none of which Laravel's container, package discovery or service provider model understands. There is no Illuminate service provider, config publishing or facade, so its realistic value is as a reference implementation for ECB and CBR endpoint handling rather than an installed dependency.
- What PHP and Laravel versions does this package support?
- The bundle is Symfony2-era, so it constrains to PHP 5.x or 7.x and Symfony roughly 2.3 to 2.8, and it likely pins Guzzle 3.x. Modern Laravel 10 and 11 require PHP 8.1+ and Guzzle 7, so Composer resolution will almost certainly fail against a current application. Forcing it with --ignore-platform-reqs leaves an abandoned HTTP stack in your dependency graph.
- How does the bundle load exchange rates from ECB and CBR providers?
- It ships two HTTP provider classes, one for ECB reference rates and one for CBR daily rates, plus a conversion service. Those providers handle the endpoint URLs, response parsing and error handling for each feed. The whole domain core is only a few hundred lines, which makes it quick to read and straightforward to reimplement.
- How do I port the currency conversion logic into a Laravel service?
- Define a Laravel-native CurrencyRateProvider contract with two adapters, ECB and optionally CBR, an ExchangeRateService for conversion, and a scheduled refresh command writing into cache or an exchange_rates table. The bundle's provider classes work well as a specification for endpoints, response shapes and error handling. Port the behaviour rather than the code, and the job is usually 200 to 400 lines.
- Does the package work with Laravel package auto-discovery?
- No. Auto-discovery relies on an extra.laravel providers entry and an Illuminate Support ServiceProvider class, and this bundle has neither. It registers itself through AppKernel, which Laravel ignores entirely. You would need to write your own service provider and configuration layer before anything worked.
- How should I cache exchange rates and detect stale data in Laravel?
- Store rates in the cache or a database table with an explicit fetched_at timestamp and a defined staleness window. Refresh them with a scheduled command on your chosen cadence and have the conversion code raise a flag when rates exceed that window. The bundle itself does not provide staleness signalling, so this is something you must add.
- Is using CBR rates from a Russian central bank feed safe for production?
- That is a product and compliance question before it is a technical one. CBR introduces a legal dimension for anything customer-facing or regulated, and both ECB and CBR have changed feed formats and access paths over time. A primary and fallback provider strategy that does not depend solely on CBR is strongly recommended.
- How do I handle monetary precision and rounding in currency conversion?
- The bundle's conversion arithmetic is float-based, which is a poor fit for settlement-grade money handling. Work in integer minor units, define an explicit rounding policy and document the rate precision you accept. If you need historical rates or audit trails, design for them up front because this package has no historical-rate storage.
- How can I test currency conversion without calling ECB or CBR in tests?
- Bind a fake implementation of your CurrencyRateProvider contract in the container and return fixed rates in your feature tests. Use HTTP fakes or recorded fixtures for adapter-level tests so parsing of the ECB and CBR payloads stays covered. That keeps the suite deterministic and free of network flakiness.
- Is redcode/currency-rate-bundle maintained, and what are the alternatives?
- The repository has zero dependents and only a few stars, so there is little evidence of production use or active maintenance. For Laravel, an actively maintained rates package with Laravel support or a thin in-house client against ECB's published feed is usually cheaper than adopting this bundle. Reimplementing the small fetching surface removes the dependency entirely.