PHPackages                             submarine/nbrb-exchange-rates-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. submarine/nbrb-exchange-rates-bundle

ActiveSymfony-bundle[Parsing &amp; Serialization](/categories/parsing)

submarine/nbrb-exchange-rates-bundle
====================================

Парсер официальных курсов валют Национального банка Республики Беларусь

v0.3.1(6y ago)6601MITPHPPHP &gt;=5.5.0CI failing

Since Dec 21Pushed 6y ago2 watchersCompare

[ Source](https://github.com/by25/NbrbExchangeRatesBundle)[ Packagist](https://packagist.org/packages/submarine/nbrb-exchange-rates-bundle)[ Docs](https://github.com/by25/NbrbExchangeRatesBundle)[ RSS](/packages/submarine-nbrb-exchange-rates-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (2)Versions (9)Used By (0)

Парсер официального курса валют НБРБ
====================================

[](#парсер-официального-курса-валют-нбрб)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/6ef53c102b1ebbf2d73fcdc344ec08e05226ef4383bf76b1e161e52d9db0ed57/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627932352f4e62726245786368616e6765526174657342756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/by25/NbrbExchangeRatesBundle/?branch=master)[![Build Status](https://camo.githubusercontent.com/e807e56be4290e4f58e79a103664fe6201555ba619bdd09760a852dd9697277c/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f627932352f4e62726245786368616e6765526174657342756e646c652f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/by25/NbrbExchangeRatesBundle/build-status/master)

Парсер официальных курсов валют Национального банка Республики Беларусь ([Источник данных](http://www.nbrb.by/statistics/Rates/XML/))

Возможности:
------------

[](#возможности)

- Получение курсов валют по коду валюты (UAH, USD).
- Получение динамики официального курса белорусского рубля к заданной валюте периодом не более чем за 365 дней.
- Все данные обернуты в объекты
- Кэширование данных (файловый кэш)

Установка
---------

[](#установка)

composer.json:

```
{
    "require": {
        "submarine/nbrb-exchange-rates-bundle": "^0.3"
    }
}
```

Регистрация бандла:

```
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
		// ...
		new Submarine\NbrbExchangeRatesBundle\SubmarineNbrbExchangeRatesBundle(),
	);
	// ...
}
```

Конфигурация `config.yml`

```
# Значения по умолчанию
submarine_nbrb_exchange_rates:
    source:                             # Урлы xml-данных
        url_exchange_rates: 'http://www.nbrb.by/Services/XmlExRates.aspx'
        url_exchange_rates_dynamic: 'http://www.nbrb.by/Services/XmlExRatesDyn.aspx'
        connect_timeout: 3              # Ожидание подключения к сервису, сек (default: 3)
        timeout: 3                      # Ожидание ответа сервера, сек (default: 3)
    exception: false                    # Выкидывать исключения? (default: false)
```

Использование
-------------

[](#использование)

### Получение текущего курса

[](#получение-текущего-курса)

```
$data = $container->get('nbrb_exchange_rates.provider')
    ->getRateExchange('USD', new \DateTime()); //За текущую дату
```

Несколько валют:

```
$provider =  $container->get('nbrb_exchange_rates.provider');

// Выбранные валюты
$data = $provider->getRatesExchanges(['UAH', 'USD', 'EUR'], new \DateTime());

// Все валюты
$data = $provider->getAllRatesExchanges(new \DateTime());

// Одна валюта
$rate = $provider->getRateExchange('USD', new \DateTime('2014-01-01'));
```

### Динамика изменения курса

[](#динамика-изменения-курса)

Период не более чем за 365 дней.

```
$container->get('nbrb_exchange_rates.provider')
    ->getRatesExchangesDynamic(
        'USD',
        new \DateTime('2014-01-01'),
        new \DateTime('2014-05-01')
    );
```

### Кэширование

[](#кэширование)

Можно воспользоваться декоратором `CachedExchangeRateProvider` в своем приложении. Кэш-провайдер должен реализовывать интерефейс `Doctrine\Common\Cache\Cache` (смотрите `doctrine/cache`).

Пример конфигурации `services.yml`:

```
services:
    my_nbrb_exchange_rates_cached:
        class: Submarine\NbrbExchangeRatesBundle\Provider\CachedExchangeRateProvider
        arguments:
            - '@nbrb_exchange_rates.provider'
            - '@cache_filesystem'
            - 10800

    cache_filesystem:
        class: Doctrine\Common\Cache\FilesystemCache
        arguments: ['%kernel.cache_dir%/file']
```

```
$provider =  $container->get('my_nbrb_exchange_rates_cached');

// Выбранные валюты
$data = $provider->getRatesExchanges(['UAH', 'USD', 'EUR'], new \DateTime());
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 50% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~258 days

Recently: every ~318 days

Total

8

Last Release

2358d ago

PHP version history (2 changes)v0.1.0PHP &gt;=5.4.0

v0.3.0PHP &gt;=5.5.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1336525?v=4)[Andrei Kulikovski](/maintainers/by25)[@by25](https://github.com/by25)

---

Top Contributors

[![by25](https://avatars.githubusercontent.com/u/1336525?v=4)](https://github.com/by25 "by25 (1 commits)")[![DKholevinsky](https://avatars.githubusercontent.com/u/10176956?v=4)](https://github.com/DKholevinsky "DKholevinsky (1 commits)")

---

Tags

belaruscurrency-exchange-ratesnbrbphp

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/submarine-nbrb-exchange-rates-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/submarine-nbrb-exchange-rates-bundle/health.svg)](https://phpackages.com/packages/submarine-nbrb-exchange-rates-bundle)
```

###  Alternatives

[sauladam/shipment-tracker

Parses tracking information for several carriers, like UPS, USPS, DHL and GLS by simply scraping the data. No need for any kind of API access.

9738.8k](/packages/sauladam-shipment-tracker)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
