PHPackages                             faridbabayev/cbar-currency - 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. faridbabayev/cbar-currency

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

faridbabayev/cbar-currency
==========================

PHP library to work with cbar.az currency rates

1.0.1(3y ago)33MITPHPPHP ^7.4|^8.0

Since Sep 8Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Faridbabayev001/cbar-currency)[ Packagist](https://packagist.org/packages/faridbabayev/cbar-currency)[ Docs](https://github.com/Faridbabayev001/cbar-currency)[ RSS](/packages/faridbabayev-cbar-currency/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (2)Versions (3)Used By (0)

PHP library to work with [CBAR](https://www.cbar.az/home?language=en) currency rates
====================================================================================

[](#php-library-to-work-with-cbar-currency-rates)

[![](https://raw.githubusercontent.com/Faridbabayev001/cbar-currency/master/screenshot.png)](https://raw.githubusercontent.com/Faridbabayev001/cbar-currency/master/screenshot.png)

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

[](#requirements)

**PHP 7.4** or higher, `simplexml` and `bcmath` extensions.

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

[](#installation)

Require this package with composer.

```
composer require faridbabayev/cbar-currency
```

#### Copy the package config to your local config with the publish command:

[](#copy-the-package-config-to-your-local-config-with-the-publish-command)

```
php artisan vendor:publish --provider="FaridBabayev\CBARCurrency\CBARCurrencyServiceProvider"
```

### Laravel without auto-discovery:

[](#laravel-without-auto-discovery)

If you don't use auto-discovery, add the ServiceProvider to the providers array in config/app.php

```
FaridBabayev\CBARCurrency\CBARCurrencyServiceProvider::class
```

If you want to use the facade to log messages, add this to your facades in app.php:

```
'CBAR' => \FaridBabayev\CBARCurrency\Facades\CBAR::class
```

Usage
-----

[](#usage)

### Fetching currencies from CBAR

[](#fetching-currencies-from-cbar)

Instantiate `FaridBabayev\CBARCurrency\Facades\CBAR` with date you want to fetch currencies for. If you don't pass a date, current date will be used:

```
use FaridBabayev\CBARCurrency\Facades\CBAR;

$currencies = CBAR::currencies(); // this will fetch currencies for current date
$currencies = CBAR::from("18.02.2022")->currencies(); // this will fetch currencies for 18.02.2022
```

You can pass dates in any format that acceptable by PHP's `strtotime()` function. For example, `20.10.2022`, `10/20/2022`, `2022-10-20`, `today`, `yesterday`, `-1 week`, `-1 year`, `15 December 2020`, `last Friday`.

### Use available drivers

[](#use-available-drivers)

You can change default driver from env file.

```
CBAR_CONNECTION=database
```

1. Default driver is `sync`:

```
use FaridBabayev\CBARCurrency\Facades\CBAR;

$currencies = CBAR::currencies(); // this will fetch currencies for current date
$currencies = CBAR::from("18.02.2022")->currencies(); // this will fetch currencies for 18.02.2022
```

2. You can use `database` driver. Before use `database` driver first run `php artisan migrate` for `currencies`table:

```
use FaridBabayev\CBARCurrency\Facades\CBAR;

$currencies = CBAR::driver('database')->currencies(); // this will fetch currencies for current date
$currencies = CBAR::driver('database')->from("18.02.2022")->currencies(); // this will fetch currencies for 18.02.2022
```

3. You can use `file` driver:

```
use FaridBabayev\CBARCurrency\Facades\CBAR;

$currencies = CBAR::driver('file')->currencies(); // this will fetch currencies for current date
$currencies = CBAR::driver('file')->from("18.02.2022")->currencies(); // this will fetch currencies for 18.02.2022
```

Converting currency
-------------------

[](#converting-currency)

All available currencies and currency codes can be found in [CBAR website](https://www.cbar.az/currency/rates?language=en)

### Converting amount to and from AZN

[](#converting-amount-to-and-from-azn)

Library supports converting given amount in foreign currency to AZN with given date's rates:

```
$currencies = CBAR::currencies();
$currencies->toAZN('USD')->convert(); // returns AZN equivalent of 1.00 USD with today's currencies
$currencies->toAZN('USD')->convert(25.53); // returns AZN equivalent of 25.53 USD with today's currencies
```

You can also convert given amount in AZN to any available foreign currency:

```
$currencies = CBAR::currencies();
$currencies->fromAZN('USD')->convert(); //  returns USD equivalent of 1.00 AZN with today's currencies
$currencies->fromAZN('USD')->convert(25.53); //  returns USD equivalent of 25.53 AZN with today's currencies
```

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

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

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Farid Babayev](https://github.com/Faridbabayev001)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

24

—

LowBetter than 31% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 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.

###  Release Activity

Cadence

Every ~0 days

Total

2

Last Release

1393d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/7c1324ec5112e57f66e32e4b9719f134e86204264a5d7c56ba7a0b4b1af8e183?d=identicon)[Farid Babayev](/maintainers/Farid%20Babayev)

---

Top Contributors

[![faridbabayev01](https://avatars.githubusercontent.com/u/97165583?v=4)](https://github.com/faridbabayev01 "faridbabayev01 (5 commits)")

---

Tags

currencyazerbaijancbarazn

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/faridbabayev-cbar-currency/health.svg)

```
[![Health](https://phpackages.com/badges/faridbabayev-cbar-currency/health.svg)](https://phpackages.com/packages/faridbabayev-cbar-currency)
```

###  Alternatives

[brick/money

Money and currency library

1.9k41.8M154](/packages/brick-money)[florianv/swap

PHP currency conversion library for retrieving exchange rates from 30+ providers, with caching and fallback.

1.3k6.8M23](/packages/florianv-swap)[cknow/laravel-money

Laravel Money

1.0k4.8M30](/packages/cknow-laravel-money)[akaunting/laravel-money

Currency formatting and conversion package for Laravel

7865.8M46](/packages/akaunting-laravel-money)[webpatser/laravel-countries

Modern Laravel Countries package providing ISO 3166-2, ISO 3166-3, currency, capital and more for all countries. Compatible with Laravel 11.x, 12.x, and 13.x.

8602.9M10](/packages/webpatser-laravel-countries)[kwn/number-to-words

Multi language standalone PHP number to words converter. Fully tested, open for extensions and new languages.

4375.4M23](/packages/kwn-number-to-words)

PHPackages © 2026

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