PHP code example of brunoinds / frankfurter-laravel

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

    

brunoinds / frankfurter-laravel example snippets


use Brunoinds\FrankfurterLaravel\Exchange;
use Brunoinds\FrankfurterLaravel\Enums\Currency;

// Get current exchange rate
$result = Exchange::now()->convert(Currency::USD, 1)->to(Currency::BRL);

// Get historical exchange rate 
$date = new DateTime('2023-12-10');
$result = Exchange::on($date)
                ->convert(Currency::USD, 1)
                ->to(Currency::BRL);
echo $result // 0.27


use Brunoinds\FrankfurterLaravel\Enums\Currency;

Currency::USD;
Currency::BRL;
Currency::EUR;
Currency::AUD;
Currency::BGN;
Currency::CAD;
Currency::CHF;
Currency::CNY;
Currency::CZK;
Currency::DKK;
Currency::GBP;
Currency::HKD;
Currency::HUF;
Currency::IDR;
Currency::ILS;
Currency::INR;
Currency::ISK;
Currency::JPY;
Currency::KRW;
Currency::MXN;
Currency::MYR;
Currency::NOK;
Currency::NZD;
Currency::PHP;
Currency::PLN;
Currency::RON;
Currency::SEK;
Currency::SGD;
Currency::THB;
Currency::TRY;
Currency::ZAR;