PHP code example of ineersa / converter

1. Go to this page and download the library: Download ineersa/converter 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/ */

    

ineersa / converter example snippets


use Ineersa\Converter\Converter;
use Ineersa\Converter\Services\EcbService;

$converter = new Converter(new EcbService());
echo $converter->convert('USD','RUB',100);

$service = new EcbService();
$service->getCurrenciesList();

$service = new EcbService();
echo $service->getRate('USD');

$cache = new MemcacheCache();
$service = new EcbService($cache);
echo $service->getRate('USD');

    $service = new OpenExchangeRatesService();
    $service->getClient()->setAppId('YOUR_APP_ID_TOKEN');
    $converter = new Converter($service);
    echo $converter->convert('USD','RUB',1);

    $service = new OpenExchangeRatesService();
    $service->getClient()->setAppId('YOUR_APP_ID_TOKEN');
    $service->getClient()->setBase('EUR');//You can control your base currency
    $service->getClient()->setSymbols('EUR,USD,RUB');//You can control what currencies you need in response
    $converter = new Converter($service);
    echo $converter->convert('USD','RUB',1);