Currency Rates Driver

This bundle comes with two currency rate providers:

Open Exchange Rates

Before using this driver you need to create your free account at

To use this driver you need to set driver ID and Open Exchange Rates API ID in your config:

    # ...
    driver: ongr_currency_exchange.open_exchange_driver
    open_exchange_rates_api_id: XXXXXX

The list of available currencies can be found here.

European Central Bank

To use this driver set ongr_currency_exchange.ecb_driver in your config.

The list of available currencies can be found here.

Adding Custom Currency Rates Driver

If you are going to use currency rates provider other than provided by this bundle you can write a driver for it by implementing CurrencyDriverInterface interface.

See example below:

// src/AppBundle/Service/CurrencyDriver.php

namespace AppBundle\Service;

use ONGR\CurrencyExchangeBundle\Driver\CurrencyDriverInterface;

class CurrencyDriver implements CurrencyDriverInterface
    public function getRates()
        return [
            'EUR' => 1,
            'USD' => 1.3345,
            'JPY' => 136.70,
    public function getBaseCurrency()
        return 'EUR';

As you can see currency driver is required to implement only two methods. One method returns a list of available currency rates, and other returns the name of base currency to which over currencies are compared.

Once you have implemented custom currency driver, register it as a service:

# app/config/services.yml
        class: AppBundle\Service\CurrencyDriver

Last, set new driver in config:

# app/config/config.yml
    # ...
    driver: app.currency_driver

Now you can test your custom driver by running currency update command:

$ app/console ongr:currency:update