Hungarian National Bank

Contents

Hungarian National Bank#

This service retrieves the data from the Hungarian National Bank (Magyar Nemzeti Bank).

Installation#

Install the service:

composer require peso/mnb-service

Install the service with all recommended dependencies:

composer require peso/mnb-service symfony/cache

This library also requires the soap extension.

Usage#

Example:

<?php

use Peso\Peso\CurrencyConverter;
use Peso\Services\HungarianNationalBankService;
use Symfony\Component\Cache\Adapter\FilesystemAdapter;
use Symfony\Component\Cache\Psr16Cache;

$cache = new Psr16Cache(new FilesystemAdapter(directory: __DIR__ . '/cache'));
$service = new HungarianNationalBankService($cache);
$converter = new CurrencyConverter($service);

// 4771875 as of 2025-11-27
echo $converter->convert('12500', 'EUR', 'HUF', 0), PHP_EOL;

// reversible (wraps service with ReversibleService)

$service = HungarianNationalBankService::reversible($cache);
$converter = new CurrencyConverter($service);

// 32.74 as of 2025-11-27
echo $converter->convert('12500', 'HUF', 'EUR', 2), PHP_EOL;

Note

Reversible Factory emits non-precise services that can only be used in informational purposes.