Download the PHP package pk305/cbk-forex without Composer
On this page you can find all versions of the php package pk305/cbk-forex. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package cbk-forex
CBK Forex — Laravel Package
A Laravel package that fetches Central Bank of Kenya (CBK) foreign exchange rates daily and stores them in your database, with a clean API for querying rates by date, currency, or history.
Features
- ✅ Fetches live rates from the CBK official data endpoint
- ✅ Stores rates with ISO currency codes and human-readable names
- ✅ Daily auto-scheduling via Laravel's task scheduler — no cron setup needed
- ✅ Artisan command for manual fetches and CI pipelines
- ✅
upsertlogic — re-running never creates duplicates - ✅ Eloquent model with helpful query scopes
- ✅ Optional API endpoints (REST)
- ✅ Optional pruning of old records
- ✅ Configurable via
.envor published config file
Requirements
| Dependency | Version |
|---|---|
| PHP | ^8.1 |
| Laravel | 10, 11, or 12 |
Installation
Publish the config (optional)
Run the migration
Scheduling (Daily Auto-Fetch)
The package automatically registers a daily scheduled command. All you need is a working Laravel scheduler. If you haven't set it up yet, add this single cron entry to your server:
By default the fetch runs at 14:00 (2 PM) EAT — after CBK typically publishes rates. Change the time in your .env:
Manual Fetch (Artisan)
Environment Variables
Usage
Using the Facade
Using the Eloquent Model Directly
REST API (Optional)
If you want to expose rates over HTTP, register these routes in your routes/api.php:
Example Responses
GET /api/cbk-forex/rates
GET /api/cbk-forex/rates/currency/USD?days=7
Supported Currencies
| CBK Label | ISO Code | Name |
|---|---|---|
| US DOLLAR | USD | US Dollar |
| STG POUND | GBP | Sterling Pound |
| EURO | EUR | Euro |
| S FRANC | CHF | Swiss Franc |
| AUSTRALIAN $ | AUD | Australian Dollar |
| CAN $ | CAD | Canadian Dollar |
| HONGKONG DOLLAR | HKD | Hong Kong Dollar |
| SINGAPORE DOLLAR | SGD | Singapore Dollar |
| CHINESE YUAN | CNY | Chinese Yuan |
| JPY (100) | JPY | Japanese Yen (per 100) |
| IND RUPEE | INR | Indian Rupee |
| DAN KRONER | DKK | Danish Krone |
| NOR KRONER | NOK | Norwegian Krone |
| SW KRONER | SEK | Swedish Krona |
| SA RAND | ZAR | South African Rand |
| SAUDI RIYAL | SAR | Saudi Riyal |
| AE DIRHAM | AED | UAE Dirham |
| KES / RWF | RWF | Rwandan Franc |
| KES / BIF | BIF | Burundian Franc |
| KES / TSHS | TZS | Tanzanian Shilling |
| KES / USHS | UGX | Ugandan Shilling |
Testing
License
MIT
All versions of cbk-forex with dependencies
illuminate/support Version ^10.0|^11.0|^12.0|^13.0
illuminate/console Version ^10.0|^11.0|^12.0|^13.0
illuminate/database Version ^10.0|^11.0|^12.0|^13.0
illuminate/http Version ^10.0|^11.0|^12.0|^13.0
guzzlehttp/guzzle Version ^7.0