symfony upgrade fixer • twig gettext extractor • wisdom • centipede • permissions handler • extraload • gravatar • locurro • country list • transliterator
💶 Local currency converter.
Imagine you have an online store, and you are selling products in many different countries. Some of your buyers might live in country that uses currency other then one you use in your store. It would be cool to give them estimation of product costs in their domestic currency.
Here is one example of showing approximate price under the brackets:
And it automatically detects users default currency based on their IP address for example.
Pretty cool, huh? 😄
<?php
/* @var $converter Locurro\Converter\Currency */
$converter->convert(
new Money\Money(100, new Money\Currency('EUR')),
new Money\Currency('RSD')
);
Full example in examples/currency.php.
<?php
/* @var $converter Locurro\Converter\Locale */
$converter->convert(
new Money\Money(100, new Money\Currency('EUR')),
'sr-Cyrl-RS'
);
Full example in examples/locale.php.
<?php
/* @var $converter Locurro\Converter\Country */
$converter->convert(
new Money\Money(100, new Money\Currency('EUR')),
'RS'
);
Full example in examples/country.php.
<?php
/* @var $converter Locurro\Converter\IpAddress */
$converter->convert(
new Money\Money(100, new Money\Currency('EUR')),
'109.92.115.78'
);
Full example in examples/ip.php.
Locurro uses Swap library for exchange rates.
There are multiple exchange rate providers supported:
- European Central Bank Supports only EUR as base currency.
- Google Finance Supports multiple currencies as base and quote currencies.
- Open Exchange Rates Supports only USD as base currency for the free version and multiple ones for the enterprise version.
- Xignite
You must have access to the
XigniteGlobalCurrencies
API. Supports multiple currencies as base and quote currencies. - Yahoo Finance Supports multiple currencies as base and quote currencies.
- WebserviceX Supports multiple currencies as base and quote currencies.
- National Bank of Romania Supports only RON as base currency.
Array
Retrieves rates from a PHP array.
You can chain them, see example in examples/ip-chained.php.
You can cache exchange rates using Doctrine cache or Illuminate cache.
Example is available in examples/ip-cached.php.
There is a Twig extension provded in the source code.