PHPackages                             phpviet/yii-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. phpviet/yii-number-to-words

ActiveYii2-extension

phpviet/yii-number-to-words
===========================

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

1.0.0(6y ago)240MITPHPPHP ^7.1

Since Jun 7Pushed 6y ago1 watchersCompare

[ Source](https://github.com/phpviet/yii-number-to-words)[ Packagist](https://packagist.org/packages/phpviet/yii-number-to-words)[ Docs](https://github.com/phpviet/yii-number-to-words)[ RSS](/packages/phpviet-yii-number-to-words/feed)WikiDiscussions master Synced yesterday

READMEChangelog (1)Dependencies (4)Versions (2)Used By (0)

 [ ![](https://avatars0.githubusercontent.com/u/993323) ](https://github.com/yiisoft)

Yii Number To Words
===================

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

 [![Latest version](https://camo.githubusercontent.com/f25b521c8b322812b30cea54b8c5dc2371d37bbf9b9f5e67d648eec03c88ac7e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870766965742f7969692d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/yii-number-to-words) [![Build status](https://camo.githubusercontent.com/94bbb4d962a000db0518345acec4d680e29438d9584741f58ebd23461e0d833c/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f706870766965742f7969692d6e756d6265722d746f2d776f7264732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phpviet/yii-number-to-words) [![Quantity score](https://camo.githubusercontent.com/9683f15394abe6bbe0c098ca6d08cc794307f3ebcad47e5d57d01b9100181edc/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706870766965742f7969692d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/phpviet/yii-number-to-words) [![StyleCI](https://camo.githubusercontent.com/598f83f67893cd1c3e12aab3e2a8e58c75e4eb3fa902fa8da7ecaa293773b9cf/68747470733a2f2f7374796c6563692e696f2f7265706f732f3139303239373738372f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/190297787) [![Total download](https://camo.githubusercontent.com/ff291889c4b2b05a2c261da352aea0c5acbef7cbeef50e564aa8e039a5a8f29b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706870766965742f7969692d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/yii-number-to-words) [![License](https://camo.githubusercontent.com/c60900cf7821af53beaac158f19f3a2496725f8bdb75e578932ffebe46e1585e/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706870766965742f7969692d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/yii-number-to-words)

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

[](#thông-tin)

Yii 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 Yii Number To Words thông qua [Composer](https://getcomposer.org):

```
composer require phpviet/yii-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 helper `phpviet\yii\numberToWords\N2WHelper`:

```
use phpviet\yii\numberToWords\N2WHelper;

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

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

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

- Sử dụng thông qua `n2w` component:

```
// mười lăm
Yii::$app->n2w->toWords(15);

// một trăm linh năm
Yii::$app->n2w->toWords(105);

// hai mươi tư
Yii::$app->n2w->toWords(24);
```

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

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

- Sử dụng thông qua helper `phpviet\yii\numberToWords\N2WHelper`:

```
use phpviet\yii\numberToWords\N2WHelper;

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

- Sử dụng thông qua `n2w` component:

```
// chín mươi lăm triệu năm trăm nghìn hai trăm đồng
Yii::$app->n2w->toCurrency(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` tại helper và component, 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 phpviet\yii\numberToWords\N2WHelper;

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

// chín nghìn bốn trăm chín mươi hai đô mười lăm xen
Yii::$app->n2w->toCurrency(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 hãy cấu hình `n2w` component trong app config file:

```
'components' => [
    'n2w' => [
        'class' => 'phpviet\yii\numberToWords\N2W',
        'dictionary' => 'standard',
        'dictionaries' => [
            'standard' => PHPViet\NumberToWords\Dictionary::class,
            'south' => PHPViet\NumberToWords\SouthDictionary::class
        ]
    ]
];
```

Ngay bây giờ bạn hãy thử đổi `dictionary` từ `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 phpviet\yii\numberToWords\N2WHelper;

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

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

 // hai mươi tư => hai mươi bốn
N2WHelper::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
N2WHelper::toCurrency(124001);
```

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

```
use phpviet\yii\numberToWords\N2WHelper;

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

// một trăm hai mươi bốn ngàn không trăm lẻ một
N2WHelper::toWords(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:

```
'components' => [
    'n2w' => [
        'class' => 'phpviet\yii\numberToWords\N2W',
        'dictionary' => 'my',
        'dictionaries' => [
            'standard' => PHPViet\NumberToWords\Dictionary::class,
            'south' => PHPViet\NumberToWords\SouthDictionary::class,
            'my' => MyDictionary::class
        ]
    ]
];
```

Và hãy thử ngay:

```
use phpviet\yii\numberToWords\N2WHelper;

// mười nhăm
N2WHelper::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

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% 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

Unknown

Total

1

Last Release

2532d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8901d64a1059726b851dbdd91463ad1d3169f9dba6a2dcff11d05f97d9bccaea?d=identicon)[vuongxuongminh](/maintainers/vuongxuongminh)

---

Top Contributors

[![vuongxuongminh](https://avatars.githubusercontent.com/u/38932626?v=4)](https://github.com/vuongxuongminh "vuongxuongminh (8 commits)")

---

Tags

number-to-wordsphpvietyii-number-to-wordsyii2-extensionphpvietyii-number-to-words

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phpviet/laravel-omnipay

Laravel Omnipay hổ trợ tích hợp các cổng thanh toán trong nước.

987.7k](/packages/phpviet-laravel-omnipay)[phpviet/omnipay-momo

Thư viện hổ trợ tích hợp cổng thanh toán MoMo.

318.3k2](/packages/phpviet-omnipay-momo)[phpviet/number-to-words

Thư viện hổ trợ chuyển đổi số sang chữ số.

219.1k5](/packages/phpviet-number-to-words)[phpviet/omnipay-vnpay

Thư viện hổ trợ tích hợp cổng thanh toán VNPay.

178.2k2](/packages/phpviet-omnipay-vnpay)[phpviet/laravel-number-to-words

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

111.7k](/packages/phpviet-laravel-number-to-words)

PHPackages © 2026

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