PHP code example of mchervenkov / bnbfixing

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

    

mchervenkov / bnbfixing example snippets



// Init BnbFixing Client
$bnbFixing = new BnbFixing();

// Return Bnb exchange rates in xml string format
$bnbFixing->getXmlContent();

// Get Certain exchange rate by code for certain bulgarian lev amount
// This will return how much Euro are 100 bulgarian lev
$bnbFixing->geExchangeBGNRateAmount('EUR', 100);

// Get Bulgarian Lev Rate for certain exchange rate and amount
// This will return how much bulgarian lev are 100 Euro
$bnbFixing->getReverseExchangeBGNRateAmount('EUR', 100);

// Get Amount between two exchange rates depends on BNB Fixings
// This will return how much euro are 100 american dollars
$bnbFixing->getExchangeRate('USD', 'EUR', 100);

BnbFixing

$bnbFixing = new BnbFixing();
$xmlContent = $bnbFixing->getXmlContent();
dd($xmlContent);

$bnbFixing = new BnbFixing();
$usd = $bnbFixing->getExchangeRateAmount('USD', 100);
dd($usd);

$bnbFixing = new BnbFixing();
$lev = $bnbFixing->getReverseExchangeRateAmount('USD', 100);
dd($lev)
bash
php artisan migrate
bash
php artisan vendor:publish --tag=bnbfixing-config
bash
php artisan vendor:publish --tag=bnbfixing-migrations
bash
php artisan vendor:publish --tag=bnbfixing-models
bash
php artisan vendor:publish --tag=bnbfixing-commands
bash
<php>
   <env name="BNB_XML_URL" value="https://www.bnb.bg/Statistics/StExternalSector/StExchangeRates/StERForeignCurrencies/?download=xml"/>
</php>