flagbit / currency-bundle
FlagbitCurrencyBundle for the Symfony Framework
Installs: 2 745
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 24
Forks: 0
Open Issues: 1
Type:symfony-bundle
Requires
- php: ^7.0
- symfony/config: ^3.4|^4.0
- symfony/dependency-injection: ^3.4|^4.0
- symfony/http-kernel: ^3.4|^4.0
- symfony/intl: ^3.4|^4.0
Requires (Dev)
- ext-intl: *
- phpunit/phpunit: ^6.0
- squizlabs/php_codesniffer: ^3.0
- twig/twig: ^1.35|^2.4.4
This package is auto-updated.
Last update: 2023-04-08 19:03:32 UTC
README
About
The FlagbitCurrencyBundle provides basic functions to display currency symbols and names.
Configuration
You can set your default currency. The bundle defaults to EUR. Currency code has to be UPPERCASE.
flagbit_currency: default_currency: EUR
Services
Fetch the global default currency.
$container->get('flagbit_currency')->getDefaultCurrency(); // EUR
Fetch the currency name. Actual output depends on your locale set.
$container->get('flagbit_currency')->getCurrencyName(); // Euro $container->get('flagbit_currency')->getCurrencyName('EUR'); // Euro $container->get('flagbit_currency')->getCurrencyName('USD'); // US Dollar
Fetch the symbol for the default currency or a given currency.
$container->get('flagbit_currency')->getCurrencySymbol(); // € $container->get('flagbit_currency')->getCurrencySymbol('EUR'); // € $container->get('flagbit_currency')->getCurrencySymbol('USD'); // $
It is recommended, that you don't fetch a service directly from a container and use dependency injection instead.
Twig
Functions
currency_name
Fetch the currency name. Actual output depends on your locale set.
{{ currency_name() }} {# example output: Euro #} {{ currency_name('EUR') }} {# example output: Euro #} {{ currency_name('USD') }} {# example output: US Dollar #}
curreny_symbol
Fetch the symbol for the default currency or a given currency.
{{ currency_symbol() }} {# example output: € #} {{ currency_symbol('CHF') }} {# example output: CHF #} {{ currency_symbol('EUR') }} {# example output: € #}
Globals
The default currency code is available as variable.
{{ currency.default }} {# example output: EUR #}