PHP library for fetching the official exchange rates published by BNR (the National Bank of Romania).
- PHP 7.1+ (tested up to PHP 8.5)
- the
simplexmlextension
composer require itrack/cursbnruse Itrack\CursBNR\CursBNR;
$curs = new CursBNR(); // downloads https://www.bnr.ro/nbrfxrates.xml
echo $curs->getCurs('EUR'); // the value as published by BNR, e.g. 4.975
echo $curs->getRate('HUF'); // per-unit rate (takes the multiplier into account)
echo $curs->getMultiplier('HUF'); // 100
echo $curs->getDate(); // publishing date, e.g. 2026-07-21
$curs->hasCurrency('USD'); // true
$curs->getCurrencies(); // ['AED', 'AUD', ... 'EUR', ...]You can also build the object from an already fetched XML document (e.g. from a cache), without any HTTP request:
$curs = CursBNR::fromXml($xmlString);All errors throw exceptions from the Itrack\CursBNR namespace:
CursBNRException- connection problems or invalid XML responseUnknownCurrencyException- the requested currency is not part of the BNR feed (extendsCursBNRException)
Both extend \RuntimeException, so an existing catch (\Exception $e)
keeps working.
composer install
composer testThe tests run against a local XML fixture, without network access. To also run the test against the live BNR feed:
CURSBNR_NETWORK_TESTS=1 composer test