rakibhstu/number-to-bangla
Composer 安装命令:
composer require rakibhstu/number-to-bangla
包简介
A Laravel package for converting English numbers into Bangla digits, Bangla words, Bangla month names, and Bangla money format with an easy-to-use API.
关键字:
README 文档
README
Laravel package to convert English numbers to Bangla number or Bangla text, Bangla month name and Bangla Money Format for Laravel 9.x, 10.x, 11.x, and 12.x.
Maximum possible number to convert in Bangla word is 999999999999999
Features
| Operation | English Input | Bangla Output |
|---|---|---|
| Text (Integer) | 13459 | তেরো হাজার চার শত ঊনষাট |
| Text (Float) | 1345.05 | এক হাজার তিন শত পঁয়তাল্লিশ দশমিক শূন্য পাঁচ |
| Number | 1345.5 | ১৩৪৫.৫ |
| Text Money Format | 1345.50 | এক হাজার তিন শত পঁয়তাল্লিশ টাকা পঞ্চাশ পয়সা |
| Month | 12 | ডিসেম্বর |
| Comma (Lakh) | 121212121 | ১২,১২,১২,১২১ |
Requirements
- PHP 8.0 or higher
- Laravel 9.x, 10.x, 11.x, or 12.x
Complete Usage Guide - NumberToBangla v2.0
🚀 Installation
composer require rakibhstu/number-to-bangla:^2.0
📖 Table of Contents
Basic Number Conversion
Number to Bangla Digits
use Rakibhstu\Banglanumber\NumberToBangla; $numto = new NumberToBangla(); echo $numto->bnNum(12345); // Output: ১২৩৪৫ echo $numto->bnNum(1234.56); // Output: ১২৩৪.৫৬
Number to Bangla Words
echo $numto->bnWord(12345); // Output: বারো হাজার তিন শত পঁয়তাল্লিশ echo $numto->bnWord(1345.05); // Output: এক হাজার তিন শত পঁয়তাল্লিশ দশমিক শূন্য পাঁচ
Comma Separated (Lakh Format)
echo $numto->bnCommaLakh(1234567); // Output: ১২,৩৪,৫৬৭
Percentage
echo $numto->bnPercentage(75.5); // Output: ৭৫.৫% echo $numto->bnPercentage(75.5, asWord: true); // Output: পঁচাত্তর দশমিক পাঁচ শতাংশ
Currency Formatting
Money Format (Taka/Paisa)
echo $numto->bnMoney(5000); // Output: পাঁচ হাজার টাকা echo $numto->bnMoney(5000.50); // Output: পাঁচ হাজার টাকা পঞ্চাশ পয়সা
Date & Time
Month Names
echo $numto->bnMonth(1); // Output: জানুয়ারি echo $numto->bnMonth(12); // Output: ডিসেম্বর
Day Names
echo $numto->bnDay(1); // Output: রবিবার echo $numto->bnDay('monday'); // Output: সোমবার
Time Formatting
echo $numto->bnTime('14:30'); // Output: দুপুর ২:৩০ echo $numto->bnTime('14:30', asWord: true); // Output: দুপুর দুইটা ত্রিশ মিনিট echo $numto->bnTime('09:15', asWord: true); // Output: সকাল নয়টা পনেরো মিনিট
Duration
echo $numto->bnDuration(3665); // Output: ১ ঘন্টা ১ মিনিট ৫ সেকেন্ড echo $numto->bnDuration(90); // Output: ১ মিনিট ৩০ সেকেন্ড
Bengali Calendar
echo $numto->bnBengaliMonth(1); // Output: বৈশাখ echo $numto->bnSeason(1); // Output: গ্রীষ্ম echo $numto->bnSeason(5); // Output: শীত
Age Calculator
echo $numto->bnAge('1990-01-15'); // Output: ৩৫ বছর echo $numto->bnAge('1990-01-15', detailed: true); // Output: ৩৫ বছর ২ মাস ৫ দিন
Date Formatting
echo $numto->bnDate('2024-01-15'); // Output: ১৫ জানুয়ারি, ২০২৪ --- ## Reverse Parsing ### Parse Bangla Numbers to English ```php $number = $numto->parseNum('১২৩৪৫'); // Output: 12345 $number = $numto->parseNum('১২,৩৪,৫৬৭'); // Output: 1234567
Fluent API
Beautiful Chaining
$result = $numto->number(12345) ->toBangla() ->asWord() ->withPrefix('মোট: ') ->withSuffix(' টাকা') ->get(); // Output: মোট: বারো হাজার তিন শত পঁয়তাল্লিশ টাকা
Different Formats
// As percentage $result = $numto->number(75.5) ->asPercentage(asWord: true) ->get(); // Output: পঁচাত্তর দশমিক পাঁচ শতাংশ
Batch Processing
Convert Multiple Numbers
$numbers = [100, 200, 300]; $result = $numto->batch($numbers, 'bnNum'); // Output: ['১০০', '২০০', '৩০০'] $result = $numto->batch($numbers, 'bnWord'); // Output: ['এক শত', 'দুই শত', 'তিন শত']
With Associative Arrays
$data = [ 'revenue' => 500000, 'expenses' => 200000, 'profit' => 300000 ]; $result = $numto->batchWithKeys($data, 'bnCurrency'); // Output: [ // 'revenue' => '৫ লক্ষ টাকা', // 'expenses' => '২ লক্ষ টাকা', // 'profit' => '৩ লক্ষ টাকা' // ]
API Integration
Convert to Array
$result = $numto->toArray(12345); /* Output: [ 'original' => 12345, 'bangla_number' => '১২৩৪৫', 'bangla_word' => 'বারো হাজার তিন শত পঁয়তাল্লিশ', 'money_format' => 'বারো হাজার তিন শত পঁয়তাল্লিশ টাকা', 'comma_format' => '১২,৩৪৫' ] */
Convert to JSON
$json = $numto->toJson(12345); // Returns UTF-8 encoded JSON string
In API Controllers
public function show($id) { $product = Product::find($id); return response()->json([ 'name' => $product->name, 'price' => NumberToBangla::convert($product->price), 'price_words' => NumberToBangla::words($product->price), 'discount' => [ 'rate' => app(NumberToBangla::class)->bnPercentage($product->discount), 'amount' => NumberToBangla::money($product->discount_amount) ], 'details' => app(NumberToBangla::class)->toArray($product->price) ]); }
Static Helpers
Quick One-Liners
use Rakibhstu\Banglanumber\NumberToBangla; // In controllers $banglaNumber = NumberToBangla::convert(12345); // In Blade {{ NumberToBangla::words($amount) }} {{ NumberToBangla::money($total) }} // In models public function getPriceAttribute($value) { return NumberToBangla::convert($value); }
Real-World Use Cases
E-Commerce
$discount = $numto->bnPercentage(20); $final = $numto->bnMoney(20000); // Stock display $stock = $numto->bnWord(50) . ' পিস';
Education
$marks = $numto->bnNum(85); $percentage = $numto->bnPercentage(85);
Official
// Official documents $amount = $numto->bnMoney(50000); $date = $numto->bnDate('2024-01-15'); $age = $numto->bnAge('1990-01-01');
Performance Tips
- Batch Processing: Use
batch()for multiple conversions - Static Helpers: Use for simple, one-off conversions
- Fluent API: Chain multiple operations efficiently
Testing
composer test
Changelog
Please see CHANGELOG for more information on what has changed recently.
Contributing
Please see CONTRIBUTING for details.
Security
If you discover any security related issues, please email rakib1708@gmail.com instead of using the issue tracker.
Credits
License
The MIT License (MIT). Please see License File for more information.
Support
If you find this package helpful, please consider giving it a ⭐ on GitHub!
rakibhstu/number-to-bangla 适用场景与选型建议
rakibhstu/number-to-bangla 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 10.85k 次下载、GitHub Stars 达 81, 最近一次更新时间为 2020 年 02 月 13 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「php」 「laravel」 「Bangla」 「laravel-package」 「bengali」 「bangla-number」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 rakibhstu/number-to-bangla 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 rakibhstu/number-to-bangla 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 rakibhstu/number-to-bangla 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Extended DateTime Class For Bangla Date and Time
A wannabe all-in-all Bangla String Manupulation Library!
Alfabank REST API integration
Extended DateTime Class For Bangla Date and Time
Numbers to Words Converter (Bangla)
This is Laravel's Bengali text converter package. Through this package, you can easily convert text from Unicode to Bijoy in your Laravel application and convert Bijoy to Unicode.
统计信息
- 总下载量: 10.85k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 81
- 点击次数: 9
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2020-02-13