yavuz/exchange-rates

Exchange rates API library

Installs: 5

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 1

Forks: 0

Open Issues: 0

pkg:composer/yavuz/exchange-rates

1.0.0 2024-09-18 10:57 UTC

This package is auto-updated.

Last update: 2025-12-29 04:08:31 UTC


README

Latest Stable Version

Exchange rates API built using Dependency Injection.

This library requires PHP >= 8.1

Installation

The recommended way to install the Exchange Rates library is through Composer:

$ composer require yavuz/exchange-rates

This command requires you to have Composer installed globally, as explained in the installation chapter of the Composer documentation.

Usage

Usage Example TCMB Driver

use Yavuz\ExchangeRates\ExchangeRate\ExchangeRate;
use Yavuz\ExchangeRates\ExchangeRate\Services\Tcmb;

require_once 'vendor/autoload.php';
require_once 'src/Config/Config.php';
require_once 'src/Helper/Helper.php';

try {
    $exchangeRatesTCMB = (new ExchangeRate(new Tcmb()))
        ->setBaseCurrency('TRY')
        ->setCurrencies(['USD', 'EUR'])
        ->setCacheTime(1800)
        ->getResult();

    dump($exchangeRatesTCMB);
} catch (Exception $e) {
    echo $e->getMessage();
}

Usage Example CurrencyAPI Driver

use Yavuz\ExchangeRates\ExchangeRate\ExchangeRate;
use Yavuz\ExchangeRates\ExchangeRate\Services\CurrencyAPI;

require_once 'vendor/autoload.php';
require_once 'src/Config/Config.php';
require_once 'src/Helper/Helper.php';

try {
    $exchangeRatesCurrencyAPI = (new ExchangeRate(new CurrencyAPI()))
        ->setAPIKey('api-key')
        ->setBaseCurrency('TRY')
        ->setCurrencies('GBP')
        ->getResult();

    dump($exchangeRatesCurrencyAPI);
} catch (Exception $e) {
    echo $e->getMessage();
}

License

Exchange Rates library is released under the MIT License. See LICENSE for details.