PHP code example of redcode / currency-rate

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

    

redcode / currency-rate example snippets


use RedCode\Currency\Rate;

// we have initialized $currencyRateManager and $currencyManager

$providerFactory = new Provider\ProviderFactory();
$providerFactory->addProvider(
  new Provider\EcbCurrencyRateProvider`(
    $currencyRateManager, 
    $currencyManager
  )
);

$converter = new CurrencyConverter(
  $providerFactory, 
  $currencyRateManager, 
  $currencyManager
);

$convertedValue = $converter->convert('USD', 'GBP', 100);