PHP code example of submarine / nbrb-exchange-rates-bundle

1. Go to this page and download the library: Download submarine/nbrb-exchange-rates-bundle library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

submarine / nbrb-exchange-rates-bundle example snippets


// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
		// ...
		new Submarine\NbrbExchangeRatesBundle\SubmarineNbrbExchangeRatesBundle(),
	);
	// ...
}

$data = $container->get('nbrb_exchange_rates.provider')
    ->getRateExchange('USD', new \DateTime()); //За текущую дату


$provider =  $container->get('nbrb_exchange_rates.provider');

// Выбранные валюты
$data = $provider->getRatesExchanges(['UAH', 'USD', 'EUR'], new \DateTime());

// Все валюты
$data = $provider->getAllRatesExchanges(new \DateTime());

// Одна валюта
$rate = $provider->getRateExchange('USD', new \DateTime('2014-01-01'));

$container->get('nbrb_exchange_rates.provider')
    ->getRatesExchangesDynamic(
        'USD', 
        new \DateTime('2014-01-01'), 
        new \DateTime('2014-05-01')
    );

$provider =  $container->get('my_nbrb_exchange_rates_cached');

// Выбранные валюты
$data = $provider->getRatesExchanges(['UAH', 'USD', 'EUR'], new \DateTime());