PHPackages                             cocolabs-sas/currency-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. cocolabs-sas/currency-bundle

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

cocolabs-sas/currency-bundle
============================

This Symfony2 bundle provide a service and a Twig extension to convert and display currencies. It is a fork of lexik/currency-bundle

v4.0.1(7mo ago)056.3k↓55.6%3MITPHPPHP &gt;=7.2.5

Since Jun 20Pushed 7mo agoCompare

[ Source](https://github.com/Cocolabs-SAS/LexikCurrencyBundle)[ Packagist](https://packagist.org/packages/cocolabs-sas/currency-bundle)[ Docs](https://github.com/lexik/LexikCurrencyBundle)[ RSS](/packages/cocolabs-sas-currency-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (2)Dependencies (10)Versions (16)Used By (0)

Overview
========

[](#overview)

This Symfony2 bundle provide a service and a twig extension to convert and display currencies.

[![Build Status](https://camo.githubusercontent.com/35f18f275b3c50fd4f0f2617c20511b2dba1994a6e9368ebdbaf0f6740415f48/68747470733a2f2f7365637572652e7472617669732d63692e6f72672f6c6578696b2f4c6578696b43757272656e637942756e646c652e706e673f6272616e63683d6d6173746572)](http://travis-ci.org/lexik/LexikCurrencyBundle)[![Latest Stable Version](https://camo.githubusercontent.com/9f71bc4d931860a14319a2a37521959abf39ffe4717a15d9e6435d47d8bc9007/68747470733a2f2f706f7365722e707567782e6f72672f6c6578696b2f63757272656e63792d62756e646c652f762f737461626c65)](https://packagist.org/packages/lexik/currency-bundle)[![SensioLabsInsight](https://camo.githubusercontent.com/64fb17d6ddd2508a9572f3276526d2e3e36f1b96cfdd8996ab9ddf214492f40a/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f30343037393231382d326164312d343339642d626661622d3163393331343638313437632f6d696e692e706e67)](https://insight.sensiolabs.com/projects/04079218-2ad1-439d-bfab-1c931468147c)

Installation
============

[](#installation)

Add the bunde to your `composer.json` file:

```
require: {
    // ...
    "lexik/currency-bundle": "~2.0"
    // ...
}
```

**As of version `1.2.0`, `currency_format` does not convert the currency anymore, it only formats the given value according to the locale. If you need to convert and format a value, please use `currency_convert_format` filter.**

Then run a composer update:

```
composer.phar update
# OR
composer.phar update lexik/currency-bundle # to only update the bundle
```

Register the bundle with your kernel:

```
// in AppKernel::registerBundles()
$bundles = array(
    // ...
    new Lexik\Bundle\CurrencyBundle\LexikCurrencyBundle(),
    // ...
);

```

Configuration
=============

[](#configuration)

Minimun configuration:

```
# app/config/config.yml
lexik_currency:
    currencies:
        default: EUR              # [required] the default currency
        managed: [EUR, USD, ...]  # [required] all currencies used in your app
```

Additional options (default values are shown here):

```
# app/config/config.yml
lexik_currency:
    decimal_part:
        precision:  2                           # number of digits for the decimal part
        round_mode: up                          # round mode to use (up|down|even|odd)
	currency_class: Lexik\Bundle\CurrencyBundle\Entity\Currency  # Use your custom Currency Entity
    default_adapter: doctrine_currency_adapter  # service id OR tag alias, this is adapter used by the conversion service
```

Initialize currencies
=====================

[](#initialize-currencies)

To initialize the currencies rate in the database run the following command:

```
./app/console lexik:currency:import

```

Example by using the ECB adapter, to get rates from the European Central Bank. In the command line `ecb` is the value returned by the `getIdentifier()` method of the adapter class.

```
./app/console lexik:currency:import ecb

```

Usage
=====

[](#usage)

##### Currency conversion service

[](#currency-conversion-service)

Use the `convert()` method from the `lexik_currency.converter` service:

```
