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.
Installs: 9 857
Dependents: 1
Suggesters: 0
Security: 0
Stars: 83
Watchers: 1
Forks: 36
pkg:composer/rakibhstu/number-to-bangla
Requires
- php: ^8.0|^8.1|^8.2|^8.3|^8.4
- illuminate/support: ^9.0|^10.0|^11.0|^12.0
- nesbot/carbon: ^2.72|^3.11
Requires (Dev)
- orchestra/testbench: ^7.0|^8.0|^9.0|^10.0
- phpunit/phpunit: ^9.5|^10.0|^11.0
This package is auto-updated.
Last update: 2026-01-12 03:59:58 UTC
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!