morbicer / converter-bundle
Currency converting bundle for Symfony2. Supports multiple exchange rate providers.
Installs: 17
Dependents: 0
Suggesters: 0
Security: 0
Stars: 3
Watchers: 1
Forks: 1
Open Issues: 0
Type:symfony-bundle
Requires
- mathiasverraes/money: ^1.3@dev
- symfony/framework-bundle: ~2.3
Suggests
- doctrine/doctrine-bundle: If you want to cache exchange rates instead of new API request every time
This package is not auto-updated.
Last update: 2025-03-19 13:23:35 UTC
README
Currency converting bundle for Symfony2. Supports multiple exchange rate providers:
- Yahoo (free)
- Google (free)
- Currency API (free)
- chain (tries multiple if some is unavailable)
proper money handling using Martin Fowler's Money pattern implemented by mathiasverraes/money
1 Installation
1.1 Composer
"require": { .... "morbicer/converter-bundle": "dev" },
or
php composer.phar require morbicer/converter-bundle
1.2 Enable the bundle
// app/AppKernel.php public function registerBundles() { $bundles = array( // ... new Morbicer\ConverterBundle\MorbicerConverterBundle(), ); }
1.3 Add config
# app/config.yml morbicer_converter: default_provider: chain providers: yahoo: [] google: [] currency_api: [] chain: [yahoo, currency_api, google]
Usage
//in controller, get service $converter = $this->get('morbicer_converter.convert'); // $100 USD to EUR $converted = $converter->convert(100, 'USD', 'EUR'); $result = array( 'amount' => $converted->getAmount()/100, 'currency' => (string)$converted->getCurrency(), );