Download the PHP package r94ever/php-currency-exchange-rate without Composer
On this page you can find all versions of the php package r94ever/php-currency-exchange-rate. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download r94ever/php-currency-exchange-rate
More information about r94ever/php-currency-exchange-rate
Files in r94ever/php-currency-exchange-rate
Package php-currency-exchange-rate
Short Description Currency exchange rate package for PHP
License MIT
Homepage https://github.com/r94ever/php-currency-exchange-rate
Informations about the package php-currency-exchange-rate
Currency exchange rate package for PHP
This package provides a simple and easy way to get currency exchange rates from various providers.
Installation
You can install the package via composer:
Usage
Current Supported Providers
Extending
This package is designed to be extensible. You can easily create a new provider to fetch rates from another source or use your own HTTP Client.
Creating a Custom Provider
To fetch exchange rate data from another API, you just need to create a new class that extends BaseProvider and
implement the convert method.
-
Create your Provider class:
-
Use the new Provider:
Instantiate
ExchangeRatewith your custom provider.
Using a Custom HTTP Client
If you want to use a different HTTP Client (e.g., Guzzle, which is already in your project) instead of the default cURL
wrapper, you can create an adapter class that implements the HttpClientInterface.
-
Create your HTTP Client class:
This class must implement
R94ever\CurrencyExchangeRate\HttpDrivers\HttpClientInterface. -
Create your HttpResponse class:
-
Inject the HTTP Client into the Provider:
When instantiating a provider that requires HTTP requests (like
ExchangeRateHost), pass the instance of your custom client into it.
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Credits
License
The MIT License (MIT). Please see License File for more information.
All versions of php-currency-exchange-rate with dependencies
ext-curl Version *