Download the PHP package brightcreations/exchange-rates without Composer

On this page you can find all versions of the php package brightcreations/exchange-rates. 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 exchange-rates

Exchange Rates Library

Downloads License Last Commit Stars Tests

A comprehensive Laravel package for fetching, storing, and managing exchange rates from various external APIs. This library provides a clean, extensible architecture for handling currency exchange rates with support for both current and historical data.

🚀 Features


📦 Installation

1. Install via Composer

2. Publish Configuration and Migrations

3. Configure Environment Variables

Add the following to your .env file:


🏗️ Architecture Overview

This library follows a clean, layered architecture:


Historical rate provider capabilities

When consuming historical rates (e.g. via brightcreations/money-converter fetchOnFail(), interpolate(), or extrapolate()), provider behaviour varies:

Provider Auto-fetch on getHistoricalExchangeRate miss Granularity Notes
OpenExchangeRateService Yes Daily Fetches and stores on ModelNotFoundException
ExchangeRateApiService Yes Daily Same as Open Exchange Rates
WorldBankExchangeRateApiService No (DB only) Yearly Pre-populate with php artisan exchange-rates:backfill
FallbackExchangeRateService Delegates to fallback order Per provider First successful provider in fallback_order wins

See money-converter historical conversion docs for how fetchOnFail, interpolate(), and extrapolate() use these capabilities.

Programmatic check:


Consuming with money-converter

brightcreations/money-converter is the recommended package for currency conversion in Laravel apps that use this library.

  1. Install both packages: composer require brightcreations/money-converter brightcreations/exchange-rates
  2. Follow the money-converter integration guide to publish configs, migrate, and populate rates
  3. money-converter's default PDO provider reads the same currency_exchange_rates tables this package writes

Version requirement: money-converter ^0.6.0 requires exchange-rates ^0.8.0 for bounding-rate repository methods used by interpolation and extrapolation.


📚 Documentation


🔧 Quick Start

Basic Usage

Historical Data

Repository Usage

Note: You can also use Laravel's resolve() or app() helpers to access the services directly:

The facades are the recommended and most convenient way for most use cases.


🌐 Built-in HTTP Endpoints

The package ships with a default read-only REST endpoint that returns exchange rates already stored in the database. It does not call any external provider — use storeExchangeRates(...) (via Artisan commands or your own code) to populate data first.

Route Configuration

Routes are enabled by default. Publish the config to customise or disable them:

The final URL is always api/{prefix}/..., so the default resolves to /api/exchange-rates/{currency}.


Normal Mode — rates from a base currency

{currency} is the base currency. Returns all stored target currencies and their rates.

Parameter Location Required Description
currency path yes ISO 4217 base currency code (3 letters, e.g. USD). Case-insensitive.
currencies query string no Comma-separated target currency codes to filter by (e.g. EUR,GBP,SAR). If omitted, all stored targets are returned.

Example — all targets

Example — filtered


Reversed Mode — rates into a target currency

{currency} becomes the target currency. Returns all stored source currencies that have a rate pointing to this target. Each rate is the stored source → target value (same direction as source_currency → target_currency).

Parameter Location Required Description
currency path yes ISO 4217 target currency code (3 letters, e.g. EUR). Case-insensitive.
reversed query string yes Must be true (or 1) to activate this mode.
currencies query string no Comma-separated source currency codes to filter by (e.g. USD,GBP). If omitted, all stored sources are returned.

Example — all sources

Example — filtered

Example — reciprocal pair lookup

Equivalent to GET /api/exchange-rates/GBP?currencies=USD when a GBP→USD row is stored:


HTTP Responses

Status Meaning
200 Success. rates is an empty array when no data is stored for that currency.
422 Validation error — invalid currency code format.

🔌 Supported APIs

The library uses an intelligent fallback mechanism. By default, it tries services in this order:

  1. Open Exchange Rates (primary)
  2. Exchange Rate API (secondary)
  3. World Bank (tertiary fallback)

Exchange Rate API

Open Exchange Rates

World Bank Exchange Rate API

Note on World Bank Data: The World Bank service provides yearly average exchange rates based on country-level data. While less precise than real-time APIs, it serves as an excellent free fallback option. Exchange rates are computed by:

  1. Fetching LCU (Local Currency Unit) per USD rates by country
  2. Mapping countries to currencies using pragmarx/countries
  3. Computing cross-currency rates from USD-anchored values

Limitations:

  • Yearly averages only (not daily/real-time)
  • Some currencies may not be available if country mapping fails
  • Aggregate regions (like "Euro Area") are filtered out automatically

🔄 Fallback Configuration

You can customise the fallback order in config/exchange-rates.php:

Or use a specific service directly:


🤝 Contributing

  1. Fork the repository
  2. Create your feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add some amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. Open a Pull Request

📄 License

This project is licensed under the MIT License — see the LICENSE file for details.

🆘 Support

For support, please contact:


Made with ❤️ by Bright Creations


All versions of exchange-rates with dependencies

PHP Build Version
Package Version
Requires php Version >=8.1
illuminate/support Version ^9.0|^10.0|^11.0|^12.0
illuminate/database Version ^10.0 || ^11.0 || ^12.0
illuminate/http Version ^10.0 || ^11.0 || ^12.0
illuminate/console Version ^10.0 || ^11.0 || ^12.0
guzzlehttp/guzzle Version ^7.9
pragmarx/countries Version ^1.0
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 brightcreations/exchange-rates contains the following files

Loading the files please wait ...