unirate-api / sylius-unirate-plugin
Sylius plugin that keeps your store's exchange rates up to date from the UniRate currency-exchange API — autowired client service plus a console command that upserts Sylius ExchangeRate entities.
Package info
github.com/UniRate-API/sylius-unirate
Type:sylius-plugin
pkg:composer/unirate-api/sylius-unirate-plugin
Requires
- php: ^8.2
- doctrine/persistence: ^3.0 || ^4.0
- sylius/currency: ^2.0
- sylius/resource: ^1.11
- symfony/config: ^6.4 || ^7.0
- symfony/console: ^6.4 || ^7.0
- symfony/dependency-injection: ^6.4 || ^7.0
- symfony/http-client: ^6.4 || ^7.0
- symfony/http-kernel: ^6.4 || ^7.0
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
None
Provides
None
Conflicts
None
Replaces
None
This package is not auto-updated.
Last update: 2026-10-22 02:47:48 UTC
README
Keep your Sylius store's exchange rates up to date from the
UniRate currency-exchange API. Sylius stores exchange
rates in the database but ships no way to refresh them automatically — this plugin
adds an autowired API client plus a console command that upserts your
ExchangeRate entities from live UniRate data.
- 170+ fiat currencies, one free API key from unirateapi.com
- Autowired
UniRateClientservice (rates, conversion, currency list) sylius:unirate:update-exchange-ratescommand — cron-friendly- Updates existing pairs in place, preserving their stored direction
- Zero runtime dependencies beyond Sylius + Symfony contracts
Installation
composer require unirate-api/sylius-unirate-plugin
Register the plugin (Symfony Flex usually does this for you):
// config/bundles.php return [ // ... UniRateApi\SyliusPlugin\UniRateSyliusPlugin::class => ['all' => true], ];
Configure your API key:
# config/packages/unirate_sylius.yaml unirate_sylius: api_key: '%env(UNIRATE_API_KEY)%' # base_url: 'https://api.unirateapi.com' # optional # timeout: 30 # optional (seconds)
# .env.local UNIRATE_API_KEY=your-key-from-unirateapi.com
Updating exchange rates
Run against your store's base currency (defaults to USD):
bin/console sylius:unirate:update-exchange-rates EUR
For every currency enabled in the store, the command upserts the exchange rate against the base currency. Schedule it with cron for hands-off rates:
0 * * * * /usr/bin/php /var/www/sylius/bin/console sylius:unirate:update-exchange-rates EUR
Using the client directly
use UniRateApi\SyliusPlugin\UniRateClient; final class PriceWidget { public function __construct(private readonly UniRateClient $unirate) {} public function eurFromUsd(float $usd): float { return $this->unirate->convert($usd, 'USD', 'EUR'); } }
License
Released under the MIT License. Powered by UniRate.