1. Go to this page and download the library: Download pk305/cbk-forex 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/ */
pk305 / cbk-forex example snippets
use Pk305\CbkForex\Facades\CbkForex;
// Manually trigger a fetch
$result = CbkForex::fetchAndStore();
// => ['fetched' => 21, 'saved' => 21, 'skipped' => 0, 'date' => '2026-04-23']
// Get the latest available rates (keyed by ISO code)
$rates = CbkForex::latestRates();
$usdRate = $rates['USD']->rate; // e.g. 129.21
// Get rates for a specific date
$rates = CbkForex::ratesForDate('2026-04-22');
// Get 30-day history for a currency
$history = CbkForex::historyForCurrency('USD', 30);
use Pk305\CbkForex\Models\ExchangeRate;
// Today's rates
ExchangeRate::forDate()->get();
// Specific date
ExchangeRate::forDate('2026-04-22')->get();
// A single currency
ExchangeRate::forCurrency('USD')->forDate()->first();
// Quick rate lookup
$rate = ExchangeRate::getRate('EUR'); // float or null
// Latest rates (most recent date in DB)
ExchangeRate::latest()->get();
// Date range
ExchangeRate::betweenDates('2026-04-01', '2026-04-23')
->forCurrency('GBP')
->orderBy('rate_date')
->get();