| Package Data | |
|---|---|
| Maintainer Username: | AlxDorosenco |
| Maintainer Contact: | alexforever1808@gmail.com (Alexei Dorosenco) |
| Package Create Date: | 2021-03-07 |
| Package Last Update: | 2024-04-21 |
| Language: | PHP |
| License: | MIT |
| Last Refreshed: | 2025-10-21 15:00:41 |
| Package Statistics | |
|---|---|
| Total Downloads: | 7,340 |
| Monthly Downloads: | 143 |
| Daily Downloads: | 2 |
| Total Stars: | 1 |
| Total Watchers: | 1 |
| Total Forks: | 1 |
| Total Open Issues: | 1 |
Currency rate convertor from European Central Bank
Url to the latest rate attributes: https://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml Url to the archived rate attributes: https://www.ecb.europa.eu/stats/eurofxref/eurofxref-hist.xml
Require this package with Composer
$ composer require alxdorosenco/ecb-rates
<?php
require __DIR__ . '/vendor/autoload.php';
use AlxDorosenco\EcbRates\CurrencyRates;
// Latest rate attributes initialization
$daily = CurrencyRates::daily();
// Exchange 20 EUR to USD
$daily->rate(20, 'EUR', 'USD');
// Exchange 20 EUR to USD - special option
$daily->euroTo(20, 'USD');
// Exchange 20 USD to JPY
$daily->rate(20, 'USD', 'JPY');
<?php
require __DIR__ . '/vendor/autoload.php';
use AlxDorosenco\EcbRates\CurrencyRates;
$history = CurrencyRates::history(); // History rate attributes initialization
// Get array of the rate attributes to the 2021-02-10 date
$history->findByDate('2021-02-10');
// Exchange 20 EUR to USD from the rate attributes to the 2021-02-10 date
$history->findByDate('2021-02-10')->rate(20, 'EUR', 'USD');
// Exchange 20 EUR to USD from the rate attributes to the 2021-02-10 date - special option
$history->findByDate('2021-02-10')->euroTo(20, 'EUR', 'USD');
// Get array of the latest rate attributes
$history->findByDate();
// Exchange 20 EUR to USD from the latest rate attributes
$history->rate(20, 'EUR', 'USD');
// Exchange 20 EUR to USD from the latest rate attributes - special option
$history->rate(20, 'EUR', 'USD')->euroTo(20, 'EUR', 'USD');
All possible currency codes: