bronanza / brutils
常见的PHP工具
dev-master
2017-10-24 15:50 UTC
Requires
- illuminate/support: ^5.4
Requires (Dev)
- peridot-php/leo: ^1.6
- peridot-php/peridot: ^1.19
This package is not auto-updated.
Last update: 2024-09-15 04:42:05 UTC
README
支持Laravel的PHP常见工具。
安装
将以下内容添加到 composer.json
文件中。然后运行 composer update
"bronanza/brutils": "dev-master"
可选
为了支持Laravel,打开 config/app.php
文件,并将服务提供者注册到 providers
数组中
Bronanza\Brutils\ServiceProvider::class
在同一个配置文件 config/app.php
中,将以下内容添加到别名数组中
NumberFormatter => Bronanza\Brutils\Number\FormatterFacade::class,
CurrencyFormatter => Bronanza\Brutils\Currency\FormatterFacade::class,
运行以下命令以发布包配置文件 config/brutils.php
php artisan vendor:publish
快速使用
格式化工具
$formatter = new \Bronanza\Brutils\Number\Formatter(0, ',', '.');
$formatter->format(10000) === '10.000';
$currencyFormatter = new \Bronanza\Brutils\Currency\Formatter($formatter, '$');
$formatter->format(10000) === '$10.000';
// Or if you've registered the facades (config based on config/brutils.php)
NumberFormatter::format(10000) === '10.000';
CurrencyFormatter::format(10000) === '$10.000';
许可证
MIT