Download the PHP package nurbekjummayev/cbu-currency without Composer

On this page you can find all versions of the php package nurbekjummayev/cbu-currency. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package cbu-currency

CBU Currency - Central Bank of Uzbekistan Exchange Rates

License: MIT PHP Version Laravel Version Tests

A Laravel package for working with Central Bank of Uzbekistan (CBU) currency exchange rates. This package provides easy-to-use methods for fetching, storing, and converting currencies with high precision using BCMath.

English version | O'zbek versiyasi

๐Ÿ“‹ Table of Contents

โœจ Features

๐Ÿ“ฆ Requirements

Note: This package targets Laravel 13 and above, which requires PHP >= 8.3.

๐Ÿš€ Installation

1. Install via Composer

2. Publish Configuration and Migrations

โš™๏ธ Configuration

Configuration file: config/cbu-currency.php

Environment Variables

Add to your .env file:

Data Source

The CBU_SOURCE configuration determines where currency rates are fetched from:

Option 1: Database (Recommended)

When using database source, you need to:

Step 1: Run Migrations

This creates two tables:

Step 2: Sync Currencies

Step 3: Fetch Exchange Rates

Option 2: API (Direct)

When using api source:

๐Ÿ“– Usage

Currency Conversion

The convert() method provides a fluent interface for currency conversion with high precision using BCMath.

Convert to UZS

Convert from UZS

Cross Currency Conversion

Using Numeric Codes

Specify Date

Change Data Source

With Caching

Get Exchange Rates

The rate() method retrieves exchange rates for specific currencies and dates.

Get Rate for Specific Date

Get All Rates

Get All Rates for Specific Date

Get Currencies List

The currencies() method retrieves available currency information.

Get Specific Currency

Get Currency Codes Only

Sync Currencies

The sync() method synchronizes currencies and rates from CBU API to your database.

Sync Both Currencies and Rates

๐Ÿ”ง Artisan Commands

The package provides two Artisan commands for managing currency data.

1. Sync Currencies

Fetch and store all available currencies from CBU API to database.

What it does:

Example output:

When to use:

2. Fetch Exchange Rates

Fetch and store exchange rates for a specific date.

What it does:

Example output:

When to use:

โฐ Auto Synchronization

For production environments, automate currency updates using Laravel's Task Scheduler.

Laravel Scheduler

Add to app/Console/Kernel.php:

Activate Scheduler

Ensure the Laravel scheduler is running by adding this to your cron:

Alternative: Direct Cron Jobs

If not using Laravel Scheduler, add cron jobs directly:

Docker/Kubernetes

For containerized environments, use supervisor or similar:

๐Ÿ—„๏ธ Database Structure

Currencies Table

Column Type Description
id bigint Primary key
ccy string Currency code (unique) - USD, EUR, RUB
name_uz string Name in Uzbek - AQSH dollari
name_oz string Name in Uzbek (Cyrillic) - ะาšะจ ะดะพะปะปะฐั€ะธ
name_ru string Name in Russian - ะ”ะพะปะปะฐั€ ะกะจะ
name_en string Name in English - US Dollar
code string Numeric code - 840
cbu_id string CBU identifier
created_at timestamp Creation time
updated_at timestamp Update time

Currency Rates Table

Column Type Description
id bigint Primary key
currency_id bigint Foreign key to currencies
date date Rate date (indexed)
currency_date date Original CBU date
rate decimal(15,4) Exchange rate - 12705.0000
diff decimal(15,4) Difference from previous - 15.2500
nominal integer Nominal value - 1
created_at timestamp Creation time
updated_at timestamp Update time

Indexes:

Unique constraint: ['currency_id', 'date'] - Only one rate per currency per day

๐Ÿงช Testing

The package provides full test coverage using Pest PHP framework.

Running Tests

For detailed testing documentation, see TESTING.md

๐ŸŒ API Endpoints

The package automatically registers RESTful API endpoints for accessing currency data.

Base URL: {your-domain}/api/cbu

1. Get All Currencies

Response:

2. Get Currency Codes

Response:

3. Get Specific Currency

Example:

Response:

4. Get Today's Rates

Response:

5. Get Rates by Date

Query Parameters:

Example:

6. Get Specific Currency Rate

Example:

Response:

7. Convert Currency

Request Body:

Response:

Validation Rules:

8. Get Conversion Rate

Returns the conversion rate for 1 unit of source currency. The optional scale query parameter (0โ€“20) rounds the final result; without it the full-precision value is returned.

Example:

Response:

Error Responses

All endpoints return a consistent error format:

Common HTTP Status Codes:

Customizing API Routes

You can enable/disable package routes and customize the route prefix in config/cbu-currency.php:

Or in .env:

If you only use the package via the CbuCurrency facade and don't need the built-in HTTP endpoints, disable them entirely:

๐Ÿค– AI / Laravel Boost Integration

This package ships with Laravel Boost AI guidelines and an agent skill (cbu-currency-development). If your project uses Boost, run:

Boost will automatically detect this package and offer to install its guidelines and skill, so AI agents (Claude Code, Cursor, Codex, etc.) know how to use the CbuCurrency facade, builders, sync commands, and API endpoints correctly. To pick up the skill after adding this package to an existing Boost setup, run php artisan boost:update --discover.

MCP Server (AI Agent Tools)

The package ships an MCP (Model Context Protocol) server that lets AI agents call currency tools directly. It activates automatically when the optional laravel/mcp package is installed:

Available tools:

Tool Description
get-rates All CBU rates for a date
get-rate Single currency rate by code and date
convert-currency Convert between currencies (optional scale for rounding)
list-currencies Currency metadata with multilingual names
sync-rates Sync rates from the CBU API into the database

The local (stdio) server is registered as cbu-currency. Connect it to your AI agent, e.g. for Claude Code:

Test it with the MCP Inspector:

Configuration (config/cbu-currency.php):

๐Ÿ“„ License

MIT License. See LICENSE file for details.

๐Ÿ‘จโ€๐Ÿ’ป Author

Nurbek Jummayev

๐Ÿ”— Useful Links


All versions of cbu-currency with dependencies

PHP Build Version
Package Version
Requires php Version ^8.1
ext-bcmath Version *
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.0
nurbekjummayev/laravel-api-response-helpers Version ^1.2
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package nurbekjummayev/cbu-currency contains the following files

Loading the files please wait ...