PHPackages                             alimranahmed/ecb-exchange - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. alimranahmed/ecb-exchange

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

alimranahmed/ecb-exchange
=========================

PHP package for ECB currency exchange rates with fluent API and SOLID architecture

01PHPCI passing

Since Sep 9Pushed 9mo agoCompare

[ Source](https://github.com/alimranahmed/ecb-exchange)[ Packagist](https://packagist.org/packages/alimranahmed/ecb-exchange)[ RSS](/packages/alimranahmed-ecb-exchange/feed)WikiDiscussions main Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

[![Test Coverage](https://raw.githubusercontent.com/alimranahmed/ecb-exchange/main/tests/coverage/badge-coverage.svg)](https://packagist.org/packages/alimranahmed/ecb-exchange)[![MIT Licence](https://camo.githubusercontent.com/fabb40ab22588a0746bb0916ed92739171bde7fb31f281c627aa588bcba62cc2/68747470733a2f2f6261646765732e66726170736f66742e636f6d2f6f732f6d69742f6d69742e7376673f763d313033)](https://opensource.org/licenses/mit-license.php)

ECB Exchange Rate PHP Package
=============================

[](#ecb-exchange-rate-php-package)

A modern, fluent PHP package for accessing European Central Bank (ECB) exchange rate data [API](https://data.ecb.europa.eu/help/api/data)

Features
--------

[](#features)

- **ECB Schedule Aware** - Handles ECB's 16:00 CET update schedule
- **Multiple Data Formats** - Single rates, collections, and time series
- **Automatic Fallbacks** - Smart date handling for weekends and holidays

Installation
------------

[](#installation)

```
composer require alimranahmed/ecb-exchange
```

Quick Start
-----------

[](#quick-start)

### Basic Usage

[](#basic-usage)

```
use EcbExchange\Ecb;

// Get a single exchange rate
$rate = Ecb::exchange()
    ->fromCurrency('USD')
    ->toCurrency('EUR')
    ->date('2025-09-01')
    ->updatedAfter('2009-05-15T14:15:00+01:00')
    ->get();

echo $rate; // "1 USD = 0.85 EUR (on 2025-09-01)"

// Convert amount
$amount = $rate->convert(100); // 85.0
```

### Multiple Currencies

[](#multiple-currencies)

```
// Get multiple exchange rates at once
$rates = Ecb::exchange()
    ->fromCurrency('EUR')
    ->toCurrencies(['USD', 'GBP', 'JPY', 'CHF'])
    ->date('2025-09-01')
    ->get();

foreach ($rates as $rate) {
    echo $rate . "\n";
}
```

### Using EUR as Base (Default)

[](#using-eur-as-base-default)

```
// When no fromCurrency is specified, EUR is used as base
$rate = Ecb::exchange()
    ->toCurrency('USD')
    ->date('2025-09-01')
    ->get();

// Same as above
$rate = Ecb::exchange()
    ->fromCurrency('EUR')
    ->toCurrency('USD')
    ->date('2025-09-01')
    ->get();
```

### Time Series Data

[](#time-series-data)

```
// Get historical data
$timeSeries = Ecb::getTimeSeries('2025-01-01', '2025-01-31', ['USD', 'GBP']);

foreach ($timeSeries as $date => $rates) {
    echo "Date: $date\n";
    foreach ($rates as $currency => $rate) {
        echo "  1 EUR = $rate $currency\n";
    }
}
```

### Get Supported Currencies

[](#get-supported-currencies)

```
$currencies = Ecb::getSupportedCurrencies();
// Returns: ['AUD', 'CAD', 'CHF', 'DKK', 'EUR', 'GBP', 'JPY', 'NOK', 'NZD', 'SEK', 'USD']
```

ECB Schedule Awareness
----------------------

[](#ecb-schedule-awareness)

This package is aware of the ECB's update schedule:

- **Update Time**: Exchange rates are updated around 16:00 CET every working day
- **Concentration Procedure**: Based on daily concertation between central banks around 14:10 CET
- **TARGET Days**: No updates on TARGET closing days
- **Weekend Handling**: Automatically uses the last working day's data for weekend requests

The package automatically handles:

- Weekend and holiday fallbacks
- Time zone considerations
- Effective date calculations based on update times

Error Handling
--------------

[](#error-handling)

The package throws `Exception` for various error conditions:

```
try {
    $rate = Ecb::exchange()
        ->fromCurrency('USD')
        ->toCurrency('EUR')
        ->date('2025-09-01')
        ->get();
} catch (Exception $e) {
    echo "Error: " . $e->getMessage();
}
```

Common error scenarios:

- Invalid currency codes
- Network connectivity issues
- API response parsing errors
- Date availability issues

Testing
-------

[](#testing)

```
composer test
```

Requirements
------------

[](#requirements)

- PHP 7.3 or higher
- Internet connection for API access

License
-------

[](#license)

MIT License. See LICENSE file for details.

Contributing
------------

[](#contributing)

1. Fork the repository
2. Create a feature branch
3. Make your changes
4. Add tests
5. Submit a pull request

Changelog
---------

[](#changelog)

### 1.0.0

[](#100)

- Initial release with basic functionality

Support
-------

[](#support)

For issues and questions, please use the GitHub issue tracker.

Disclaimer
----------

[](#disclaimer)

This package is for informational purposes only. The ECB reference rates are published for information purposes only, and using the rates for transaction purposes is strongly discouraged.

###  Health Score

15

—

LowBetter than 3% of packages

Maintenance40

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity14

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/b8c3fefb2074087ffdd55e9ebc7186a690d78ff1c23d059e6ccf68303eda0ad2?d=identicon)[al\_imran](/maintainers/al_imran)

---

Top Contributors

[![alimranahmed](https://avatars.githubusercontent.com/u/7629427?v=4)](https://github.com/alimranahmed "alimranahmed (1 commits)")

### Embed Badge

![Health badge](/badges/alimranahmed-ecb-exchange/health.svg)

```
[![Health](https://phpackages.com/badges/alimranahmed-ecb-exchange/health.svg)](https://phpackages.com/packages/alimranahmed-ecb-exchange)
```

PHPackages © 2026

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