Download the PHP package cmbuckley/exchange-rates without Composer

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

Latest Version on Packagist Build Status Total Downloads PHP from Packagist GitHub license

Table of Contents

Overview

Exchange Rates is a simple PHP package used for interacting with the exchangerate.host API. You can use it to get the latest or historical exchange rates and convert monetary values between different currencies and cryptocurrencies.

Installation

You can install the package via Composer:

The package has been developed and tested to work with the following minimum requirements:

Usage

Setup

The exchangerate.host service requires an access key, which you can sign up and request for free. You need to add a payment card to get the key, but you won't be charged if you're on the free plan. You are resticted to 100 requests per month on the free plan.

Set the API key as follows:

The API also does not support HTTPS on the free plan. If you are on a paid plan and want to use HTTPS, pass the tls service option:

Methods

Available Currencies

To get the available currencies that are supported by the package, you can use the currencies() method like so:

Exchange Rate Between Two Currencies

To get the exchange for one currency to another, you can use the exchangeRate() method.

The example below shows how to get the exchange rate from GBP to EUR for today:

If a valid date is passed as the third parameter, the exchange rate for that day will be returned. If no date is passed, today's exchange rate will be used.

Exchange Rate Between More Than Two Currencies

It is possible to get the exchange rates for multiple currencies in one call. This can be particularly useful if you are needing to get many exchange rates at once and do not want to make multiple API calls.

To do this, you can use exchangeRate() method and pass an array of currency code strings as the second parameter. This will return an array containing the exchange rates as strings:

As above, you can pass a date as the third parameter to get the exchange rates for that day.

Exchange Rates Between Date Range

To get the exchange rates between two currencies and a range of dates, you can use the exchangeRateBetweenDateRange() method.

The example below shows how to get the exchange rates from GBP to EUR for the past 3 days:

As before, you can pass an array of currency codes as the second parameter:

Convert Currencies

Similar to how you can get the exchange rate from one currency to another, you can also convert a monetary value from one currency to another. To do this you can use the convert() method.

When passing in the monetary value (first parameter) that is to be converted, it's important that you pass it in the lowest denomination of that currency. For example, £1 GBP would be passed in as 100 (as £1 = 100 pence).

The example below shows how to convert £1 to EUR at today's exchange rate:

If a valid date is passed as the third parameter, the exchange rate for that day will be used. If no date is passed, today's exchange rate will be used.

You can also use the convert() method to convert a monetary value from one currency to multiple currencies. To do this, you can pass an array of currency codes strings as the third parameter:

Convert Currencies Between Date Range

Similar to getting the exchange rates between a date range, you can also get convert monetary values from one currency to another using the exchange rates. To do this you can use the convertBetweenDateRange() method:

You can also convert to multiple currencies:

Testing

To run the tests for the package, you can use the following command:

Contribution

If you wish to make any changes or improvements to the package, feel free to make a pull request.

To contribute to this library, please use the following guidelines before submitting your pull request:

Credits

Changelog

Check the CHANGELOG to get more information about the latest changes.

License

The MIT License (MIT). Please see License File for more information.


All versions of exchange-rates with dependencies

PHP Build Version
Package Version
Requires php Version ^8.2
guzzlehttp/guzzle Version ^7.0
ext-json Version *
ext-bcmath Version *
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 cmbuckley/exchange-rates contains the following files

Loading the files please wait ....