- Does lexik/currency-bundle work with Laravel?
- No. It is a Symfony2 bundle, not a framework-agnostic library: its value is wired through Symfony's DependencyInjection extension and consumed via $container->get('lexik_currency.converter'), with presentation delivered as a Twig extension. Laravel has no bundle or DI-extension concept and the package does not target illuminate/*, so there is no drop-in integration path. Treat it as a reference implementation rather than a dependency.
- Can I composer require lexik/currency-bundle in a Laravel 10 or 11 app?
- It will almost certainly fail or drag in Symfony 2.x components that conflict with Laravel's symfony/* v6/v7 constraints. Forcing it with --ignore-platform-reqs inherits an unmaintained transitive tree with PHP constraints around ^5.3|^7.0. The recommended decision is not to require it at all.
- What does lexik/currency-bundle actually contain?
- Roughly three things: conversion math (rate multiply plus rounding, around 50 LOC), an ECB exchange-rate provider that fetches and parses XML (around 100–200 LOC), and Symfony-specific glue such as DI configuration, Twig filters, form types and a Doctrine entity for rates. Only the ECB provider is a genuine asset. Everything else is either trivial or conflicts with the Laravel stack.
- Why is the Doctrine persistence in this bundle a problem for Laravel?
- The bundle persists rates through Doctrine ORM entities, which conflicts with Eloquent and would put a foreign schema in your application. If a side-by-side evaluation is mandated, isolate the bundle behind an adapter and never let its Doctrine entity into the application schema. Instead persist to a currency_rates table keyed on base, quote, rate, as_of and source.
- How do I port the ECB exchange rate provider into a Laravel service?
- Port the fetcher into app/Services/Fx/EcbRateProvider.php implementing a first-party ExchangeRateProvider interface, using Laravel's HTTP client and SimpleXMLElement for the XML parse. Persist results to a currency_rates table and bind the interface in a service provider. Wrap reads in Cache::remember with a 15–60 minute TTL.
- Should I use moneyphp/money or brick/money for currency math in Laravel?
- Either works as the arithmetic layer; the evaluation recommends moneyphp/money or brick/money instead of the bundle's multiply-and-round helper. Define your own ExchangeRateProvider interface so the rate source stays swappable, and keep formatting in a Blade component or a format() helper. This avoids pulling any Symfony2 artifacts into the app.
- How do I replace the bundle's Twig currency filters in Blade?
- The Twig extension is useless in Blade, so replace it with Blade components plus a Money cast or accessor and a format() helper. That keeps formatting consistent across views without pulling Twig into a Laravel app. It is a small amount of work compared to adapting the Symfony extension.
- How do I schedule daily exchange rate refreshes in Laravel?
- Schedule an fx:refresh-rates command in routes/console.php to run after roughly 16:00 CET on TARGET business days, when the ECB publishes reference rates. The command should call your EcbRateProvider, upsert into currency_rates with an as_of timestamp and source, and let the cache layer absorb reads. Compute cost is negligible, so throughput is bounded by cache hit rate.
- Do I need live FX rates or a periodic rate table?
- Most commerce and pricing cases need a periodic rate table rather than live rates, which makes the bundle's value proposition even thinner. Decide up front, then settle which currencies you support, your rounding policy (half-up, bankers, ISO 4217 minor units), and whether accounting or legal rules require recorded rate provenance and as_of timestamps. Historical rates matter if you handle refunds, reporting, or reconciliation.
- Is lexik/currency-bundle still maintained and safe to use in production?
- Symfony2 has been EOL since 2018, PHP constraints are likely ^5.3|^7.0, and there is no security patching or CVE process. The repository has around 58 stars and no dependents, meaning effectively no third-party review, and the ECB feed is a single upstream with no fallback provider in the bundle. If vendored or forked you own it outright, so budget maintenance from day one.