Download the PHP package sprain/currency-converter without Composer
On this page you can find all versions of the php package sprain/currency-converter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download sprain/currency-converter
More information about sprain/currency-converter
Files in sprain/currency-converter
Package currency-converter
Short Description A php library to handle currency conversion
License MIT
Homepage https://github.com/sprain/CurrencyConverter
Informations about the package currency-converter
SprainCurrencyConverter
SprainCurrencyConverter is a php library to convert currencies. It allows great flexibility by use of built-in or custom providers.
Installation
Add SprainCurrencyConverter to your composer.json:
{
"require": {
"sprain/currency-converter": "~0.1"
}
}
Now tell composer to download the bundle by running the command:
$ php composer.phar update sprain/currency-converter
Usage
Providers
Included providers
-
FixerIoProvider
Exchange rates provided by fixer.io, which gets its data from the European Central Bank.
Supported currencies: No restrictions defined -
SwissGovernmentProvider
Exchange rates provided by the Swiss government. See www.estv.admin.ch.
Supported currencies: CHF - YahooProvider
Exchange rates provided by finance.yahoo.com.
Supported currencies: No restrictions defined
Create your own custom provider
SprainCurrencyConverter easily allows you to add your own custom provider. This is helpful if for instance you keep exchange rates locally in a database.
It's simple:
Caching in custom providers
If your provider uses a remote api or any other method which takes some time to get data, you might want to cache the exchange rate.
To achieve this, simply extend AbstractCacheableProvider
instead of AbstractProvider
:
If a cache was injected into CurrencyConverter
, every exchange rate fetched by your provider will now automatically be cached for 24 hours.
License
This library is under the MIT license. See the complete license in:
Resources/meta/LICENSE