PHPackages                             kiendaotac/laravel-number-to-words - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. kiendaotac/laravel-number-to-words

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

kiendaotac/laravel-number-to-words
==================================

Laravel number to words hổ trợ chuyển đổi số sang chữ số Tiếng Việt.

2.0.1(5y ago)01321MITPHP

Since Jun 6Pushed 3y agoCompare

[ Source](https://github.com/kiendaotac/laravel-number-to-words)[ Packagist](https://packagist.org/packages/kiendaotac/laravel-number-to-words)[ Docs](https://github.com/phpviet/laravel-number-to-words)[ RSS](/packages/kiendaotac-laravel-number-to-words/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

 [ ![](https://avatars0.githubusercontent.com/u/958072) ](https://github.com/laravel)

Laravel Number To Words
=======================

[](#laravel-number-to-words)

 [![Latest version](https://camo.githubusercontent.com/35a8de9073cb7c9066f149e7f85de37c34b43cf482e28f46902adeed84439ae2/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870766965742f6c61726176656c2d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/laravel-number-to-words) [![Build status](https://camo.githubusercontent.com/6f667e1ba83f6eaed2e7e4b59c1b05d0f3dcbe7c45f434e83ca98883f7ede4a5/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f706870766965742f6c61726176656c2d6e756d6265722d746f2d776f7264732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phpviet/laravel-number-to-words) [![Quantity score](https://camo.githubusercontent.com/a98374ff67a44bded503bd768db7bc2003f374f2275015f38190c09fa35389c7/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706870766965742f6c61726176656c2d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/phpviet/laravel-number-to-words) [![StyleCI](https://camo.githubusercontent.com/fd82cf2e47ade6db9cc14752d5049bc2e4b764ca68449303e2311ac4d87b8ae0/68747470733a2f2f7374796c6563692e696f2f7265706f732f3139303239373736362f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/190297766) [![Total download](https://camo.githubusercontent.com/7612ef9aa3d8171d5d44168f115aeae2e9cc39cda88b8b8b3e9a1373f8cf89d1/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706870766965742f6c61726176656c2d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/laravel-number-to-words) [![License](https://camo.githubusercontent.com/b8a6e1e261f36eaf33394a1fc772c8b3c0a0182a14d385edc4737ddec90147cc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706870766965742f6c61726176656c2d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/laravel-number-to-words)

Thông tin
---------

[](#thông-tin)

Laravel number to words hổ trợ chuyển đổi số sang chữ số Tiếng Việt.

Cài đặt
-------

[](#cài-đặt)

Cài đặt Laravel Number To Words thông qua [Composer](https://getcomposer.org):

```
composer require phpviet/laravel-number-to-words
```

Cách sử dụng
------------

[](#cách-sử-dụng)

### Các tính năng của extension:

[](#các-tính-năng-của-extension)

- [`Chuyển đổi số sang chữ số`](#Chuy%E1%BB%83n-%C4%91%E1%BB%95i-s%E1%BB%91-sang-ch%E1%BB%AF-s%E1%BB%91)
- [`Chuyển đổi số sang tiền tệ`](#Chuy%E1%BB%83n-%C4%91%E1%BB%95i-s%E1%BB%91-sang-ti%E1%BB%81n-t%E1%BB%87)
- [`Thay cách đọc số`](#Thay-c%C3%A1ch-%C4%91%E1%BB%8Dc-s%E1%BB%91)

### Chuyển đổi số sang chữ số

[](#chuyển-đổi-số-sang-chữ-số)

- Sử dụng thông qua facade `N2W`:

```
use N2W;

// âm năm
N2W::toWords(-5);

// năm
N2W::toWords(5);

// năm phẩy năm
N2W::toWords(5.5);
```

- Sử dụng thông qua hàm hổ trợ `n2w`:

```
// mười lăm
n2w(15);

// một trăm linh năm
n2w(105);

// hai mươi tư
n2w(24);
```

### Chuyển đổi số sang tiền tệ

[](#chuyển-đổi-số-sang-tiền-tệ)

- Sử dụng thông qua facade `N2W`:

```
use N2W;

// năm triệu sáu trăm chín mươi nghìn bảy trăm đồng
N2W::toCurrency(5690700);
```

- Sử dụng thông qua hàm hổ trợ `n2c`:

```
// chín mươi lăm triệu năm trăm nghìn hai trăm đồng
n2c(95500200);
```

Ngoài ra ta còn có thể sử dụng đơn vị tiền tệ khác thông qua tham trị thứ 2 của phương thức `toCurrency` và hàm `n2c` với mảng phần từ đầu tiên là đơn vị cho số nguyên và kế tiếp là đơn vị của phân số:

```
use N2W;

// sáu nghìn bảy trăm bốn mươi hai đô bảy xen
N2W::toCurrency(6742.7, ['đô', 'xen']);

// chín nghìn bốn trăm chín mươi hai đô mười lăm xen
n2c(9492.15, ['đô', 'xen']);
```

### Thay cách đọc số

[](#thay-cách-đọc-số)

> Nếu như bạn cảm thấy cách đọc ở trên ổn rồi thì hãy bỏ qua bước này.

Đầu tiên để thay đổi cách đọc số bạn cần phải publish file cấu hình thông qua câu lệnh:

```
php artisan vendor:publish --provider="PHPViet\Laravel\NumberToWords\ServiceProvider" --tag="config"
```

Sau khi publish xong ta sẽ có được file config `config/n2w.php` như sau:

```
return [
    /**
     * Cấu hình từ điển mặc định theo chuẩn chung của cả nước
     */
    'defaults' => [
        'dictionary' => 'standard',
    ],
    'dictionaries' => [
        /**
         * Cấu hình các từ điển custom theo ý bạn.
         */
        'standard' => PHPViet\NumberToWords\Dictionary::class,
        'south' => PHPViet\NumberToWords\SouthDictionary::class
    ]
];
```

Ngay bây giờ bạn hãy thử đổi default `standard` sang `south`, toàn bộ phương thức chuyển đổi số sang chữ số và tiền tệ sẽ đọc theo phong cách trong Nam:

```
use N2W;

// một trăm linh một => một trăm lẻ một
N2W::toWords(101);

// một nghìn => một ngàn
N2W::toWords(1000);

 // hai mươi tư => hai mươi bốn
N2W::toWords(24);

// một trăm hai mươi tư nghìn không trăm linh một đồng => một trăm hai mươi bốn ngàn không trăm lẻ một đồng
N2W::toCurrency(124001);
```

hoặc bạn muốn sử dụng linh động hơn thì hãy chỉ định từ điển:

```
// một trăm hai mươi tư nghìn không trăm linh một
n2w(124001);

// một trăm hai mươi bốn ngàn không trăm lẻ một
n2w(124001, 'south');
```

Nếu như bạn muốn thay đổi cách đọc theo ý bạn thì hãy tạo một lớp `Dictionary` kế thừa `PHPViet\NumberToWords\Dictionary` hoặc thực thi mẫu trừu tượng `PHPViet\NumberToWords\DictionaryInterface`:

```
use PHPViet\NumberToWords\Dictionary;
use PHPViet\NumberToWords\Transformer;

class MyDictionary extends Dictionary {

    /**
     * @inheritDoc
     */
    public function specialTripletUnitFive(): string
    {
        return 'nhăm';
    }

}
```

Sau đó khai báo vào config:

```
return [
    /**
     * Cấu hình từ điển mặc định theo chuẩn chung của cả nước
     */
    'defaults' => [
        'dictionary' => 'my',
    ],
    'dictionaries' => [
        /**
         * Cấu hình các từ điển custom theo ý bạn.
         */
        'standard' => PHPViet\NumberToWords\Dictionary::class,
        'south' => PHPViet\NumberToWords\SouthDictionary::class,
        'my' => MyDictionary::class
    ]
];
```

Và hãy thử ngay:

```
use N2W;

// mười nhăm
N2W::toWords(15);
```

Dành cho nhà phát triển
-----------------------

[](#dành-cho-nhà-phát-triển)

Nếu như bạn cảm thấy extension còn thiếu sót hoặc sai sót và bạn muốn đóng góp để phát triển chung, chúng tôi rất hoan nghênh! Hãy tạo các `issue` để đóng góp ý tưởng cho phiên bản kế tiếp hoặc tạo `PR` để đóng góp. Cảm ơn!

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 76.7% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~347 days

Total

3

Last Release

1839d ago

Major Versions

1.0.0 → 2.0.02021-04-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/9ccb39ec31b5fbb25b9353d80e3c6e44d361da394064f365596caa52376d0b12?d=identicon)[kiendaotac](/maintainers/kiendaotac)

---

Top Contributors

[![vuongxuongminh](https://avatars.githubusercontent.com/u/38932626?v=4)](https://github.com/vuongxuongminh "vuongxuongminh (23 commits)")[![nhamtphat](https://avatars.githubusercontent.com/u/20165130?v=4)](https://github.com/nhamtphat "nhamtphat (6 commits)")[![kiendaotac](https://avatars.githubusercontent.com/u/29721777?v=4)](https://github.com/kiendaotac "kiendaotac (1 commits)")

---

Tags

phpvietlaravel-number-to-words

### Embed Badge

![Health badge](/badges/kiendaotac-laravel-number-to-words/health.svg)

```
[![Health](https://phpackages.com/badges/kiendaotac-laravel-number-to-words/health.svg)](https://phpackages.com/packages/kiendaotac-laravel-number-to-words)
```

###  Alternatives

[barryvdh/laravel-ide-helper

Laravel IDE Helper, generates correct PHPDocs for all Facade classes, to improve auto-completion.

14.9k123.0M687](/packages/barryvdh-laravel-ide-helper)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/pagination

The Illuminate Pagination package.

10532.5M862](/packages/illuminate-pagination)[spatie/laravel-pjax

A pjax middleware for Laravel 5

513371.8k11](/packages/spatie-laravel-pjax)[spatie/laravel-mix-preload

Add preload and prefetch links based your Mix manifest

169176.0k2](/packages/spatie-laravel-mix-preload)[mrmarchone/laravel-auto-crud

Laravel Auto CRUD helps you streamline development and save time.

28711.8k2](/packages/mrmarchone-laravel-auto-crud)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
