antonienko/money-formatter
Composer 安装命令:
composer require antonienko/money-formatter
包简介
Formatter for moneyphp/money library using alcohol/iso4217 for obtaining the number of decimal digits in each currency
README 文档
README
Class to convert Moneyphp/money objects to the base unit representation of the given currency (float) or to a string representation given a locale, using php's intl extension.
To do so it leverages the info provided by the iso4217 library from Alcohol in order to know the exact number of decimal places that each currency uses.
##Installation ###Composer This library is available in packagist.org, you can add it to your project via Composer.
In the "require" section of your composer.json file:
Always up to date (bleeding edge, API not guaranteed stable)
"antonienko/money-formatter": "dev-master"
Specific minor version, API stability
"antonienko/money-formatter": "2.0.*"
Features
- Convert a Money Object to float value, depending on the number of decimal places used by the currency.
- Convert a Money Object to string, formatted using the provided locale.
- Get the currency symbol of a Money Object, either just the symbol or the full currency symbol (The "just the symbol" option for Canadian Dollar would be '$', but if you are in the USA you would need the "full symbol" option "CA$")
- Get the symbol position for a given locale (right or left position)
##Sample Usage
use antonienko\MoneyFormatter\MoneyFormatter; use Money\Currency; use Money\Money; $some_euros = new Money(300005, new Currency('EUR')); $some_dollars = new Money(300005, new Currency('USD')); $mf = new MoneyFormatter('fr_FR'); $amount = $mf->toFloat($some_euros); //$amount will be (float)3000.05 $french_formatted = $mf->toString($some_euros); //$french_formatted will be '3 000,05 €' $just_symbol = $mf->toSymbol($some_dollars); //$just_symbol would be '$' $full_symbol = $mf->toSymbol($some_dollars, false); //$full_symbol would be '$US' $position = $mf->getSymbolPosition($some_euros); //position would be MoneyFormatter::SYMBOL_POSITION_RIGHT
##License Information Licensed under The MIT License (MIT). See the LICENSE file for more details.
antonienko/money-formatter 适用场景与选型建议
antonienko/money-formatter 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 3.86k 次下载、GitHub Stars 达 3, 最近一次更新时间为 2015 年 07 月 14 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「money」 「currency」 「formatter」 「Value Object」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 antonienko/money-formatter 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 antonienko/money-formatter 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 antonienko/money-formatter 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Beyonic PHP Library
Yii2 phone formatter and validator.
Custom laravel monolog logger for datadog logs management, both api and agent ways
An less opinionated version of Laravel Pint.
Fixer.io data provider for Peso
TCMB Currenct Converter
统计信息
- 总下载量: 3.86k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 4
- 点击次数: 22
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-07-14