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

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

phpviet/symfony-number-to-words
===============================

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

1.0.0(6y ago)13MITPHPPHP ^7.1

Since Jun 8Pushed 6y ago1 watchersCompare

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

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

 [ ![](https://avatars0.githubusercontent.com/u/143937) ](https://github.com/symfony)

Symfony Number To Words
=======================

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

 [![Latest version](https://camo.githubusercontent.com/80c7191297a615eeba53dd6be5f8347099ad70c8b324d1d304f9c613f9de002a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f706870766965742f73796d666f6e792d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/symfony-number-to-words) [![Build status](https://camo.githubusercontent.com/7086cf23aafb54a1c42c20015dae47f91441ee517abcbc4c7decd569d161e79b/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f706870766965742f73796d666f6e792d6e756d6265722d746f2d776f7264732f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/phpviet/symfony-number-to-words) [![Quantity score](https://camo.githubusercontent.com/7365dc3cc4f97a17d3099117c7a85c7201f9ef88bed28957cb80a15dbc1e5b07/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f706870766965742f73796d666f6e792d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/phpviet/symfony-number-to-words) [![StyleCI](https://camo.githubusercontent.com/7ea624f1dd14e239e3249ec82dcb96ffa346843b81e58113faa6bfde41c40e92/68747470733a2f2f7374796c6563692e696f2f7265706f732f3139303239373830312f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/190297801) [![Total download](https://camo.githubusercontent.com/fe6186a684fa07633204fc0a78fb05e974e560dd35d9a06d03fc0d582bc867d8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f706870766965742f73796d666f6e792d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/symfony-number-to-words) [![License](https://camo.githubusercontent.com/9dc4341197f961bcedb34a3dde55b424057d458483fa17ab59218ba877839d8f/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f706870766965742f73796d666f6e792d6e756d6265722d746f2d776f7264732e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/phpviet/symfony-number-to-words)

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

[](#thông-tin)

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

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

- Tiếp đến hãy khai báo bundle tại `config/bundles.php`:

```
// config/bundles.php

return [
    .....
    PHPViet\Symfony\NumberToWords\Bundle::class => ['all' => true]
];
```

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 service `n2w`:

```
// âm năm
$container->get('n2w')->toWords(-5);

// năm
$container->get('n2w')->toWords(5);

// năm phẩy năm
$container->get('n2w')->toWords(5.5);
```

- Sử dụng trong `twig` với `n2w` filter:

```
// mười lăm
{{ 15 | n2w }};

// một trăm linh năm
{{ 105 | n2w }};

// hai mươi tư
{{ 24 | n2w }};
```

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

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

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

```
// năm triệu sáu trăm chín mươi nghìn bảy trăm đồng
$container->get('n2w')->toCurrency(5690700);
```

- Sử dụng trong `twig` với `n2c` filter:

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

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à filter `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ố:

```
// sáu nghìn bảy trăm bốn mươi hai đô bảy xen
$container->get('n2w')->toCurrency(6742.7, ['đô', 'xen']);

// chín nghìn bốn trăm chín mươi hai đô mười lăm xen
{{ 9492.15 | n2c(['đô', '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 tạo file cấu hình `n2w.yaml` trong `config/packages` với nội dung sau:

```
n2w:
    defaults:
        dictionary: 'standard'
    dictionaries:
        standard: 'n2w_standard_dictionary'
        south: 'n2w_south_dictionary'
```

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:

```
// một trăm linh một => một trăm lẻ một
$container->get('n2w')->toWords(101);

// một nghìn => một ngàn
$container->get('n2w')->toWords(1000);

 // hai mươi tư => hai mươi bốn
$container->get('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
$container->get('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
{{ 124001 | n2w }};

// một trăm hai mươi bốn ngàn không trăm lẻ một
{{ 124001 | n2w('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 đó đăng ký 1 service cho nó, ví dụ ta sẽ đặt service đại diện cho `MyDictionary` là `app.my`tiếp đến khai báo file `n2w.yaml` như sau:

```
n2w:
    defaults:
        dictionary: 'myDictionary'
    dictionaries:
        standard: 'n2w_standard_dictionary'
        south: 'n2w_south_dictionary'
        myDictionary: 'app.my'
```

Và hãy thử ngay:

```
// mười nhăm
$container->get('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

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

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

2530d 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 (14 commits)")

---

Tags

number-to-wordsphpvietsymfony-bundlesymfony-number-to-wordsphpvietsymfony-number-to-words

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[winzou/state-machine-bundle

Bundle for the very lightweight yet powerful PHP state machine

34010.4M15](/packages/winzou-state-machine-bundle)[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[sylius/taxonomy-bundle

Flexible categorization system for Symfony.

26388.2k7](/packages/sylius-taxonomy-bundle)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[sylius/addressing-bundle

Addressing and zone management for Symfony applications.

33221.4k3](/packages/sylius-addressing-bundle)[sylius/inventory-bundle

Flexible inventory management for Symfony applications.

19176.7k4](/packages/sylius-inventory-bundle)

PHPackages © 2026

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