PHPackages                             yiiviet/yii2-n2w - 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. yiiviet/yii2-n2w

AbandonedArchivedYii2-extension[Utility &amp; Helpers](/categories/utility)

yiiviet/yii2-n2w
================

Behavior hổ trợ chuyển đổi số sang chữ số.

1.0.0(8y ago)223BSD-3-ClausePHPPHP &gt;=5.6

Since May 30Pushed 8y ago1 watchersCompare

[ Source](https://github.com/yiiviet/yii2-n2w)[ Packagist](https://packagist.org/packages/yiiviet/yii2-n2w)[ RSS](/packages/yiiviet-yii2-n2w/feed)WikiDiscussions master Synced yesterday

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

YII2 Việt Nam N2W
=================

[](#yii2-việt-nam-n2w)

**Yii2 Extension hổ trợ bạn chuyển đổi số sang chữ số.**

[![Latest Stable Version](https://camo.githubusercontent.com/ea0ffdcd5973f67023a3e22adaf138a0113b0896f3f24e1b2fda7af056213e73/68747470733a2f2f706f7365722e707567782e6f72672f796969766965742f796969322d6e32772f762f737461626c65)](https://packagist.org/packages/yiiviet/yii2-n2w)[![Total Downloads](https://camo.githubusercontent.com/c159aa2f50cb8907fc9fa8e28a907f5fb2446bd657fd2772b36b17e32723dd04/68747470733a2f2f706f7365722e707567782e6f72672f796969766965742f796969322d6e32772f646f776e6c6f616473)](https://packagist.org/packages/yiiviet/yii2-n2w)[![Build Status](https://camo.githubusercontent.com/e5f975d67ee4d5b5f42150dc525fb0c7a0463d47798d595464ade6251998ca1e/68747470733a2f2f7472617669732d63692e6f72672f796969766965742f796969322d6e32772e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/yiiviet/yii2-n2w)[![Scrutinizer Code Quality](https://camo.githubusercontent.com/e2296147239b9fa342d800991a8840521d0b73661e049044dbf731fce706b967/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796969766965742f796969322d6e32772f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yiiviet/yii2-n2w/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/1a8bcf33a6962d920b533a075c97acbe20ca1f008b6cfebca742b55631e17816/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f796969766965742f796969322d6e32772f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/yiiviet/yii2-n2w/?branch=master)[![Yii2](https://camo.githubusercontent.com/d6b0929173e28cc627430d2519ca1853466a70f37395877eaf4820cb3e1e1909/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f77657265645f62792d5969695f4672616d65776f726b2d677265656e2e7376673f7374796c653d666c6174)](http://www.yiiframework.com/)

Chuyển đổi số sang chữ số là một phần không thể thiếu khi xây dựng chức năng in hóa đơn hoặc các chức năng liên quan đến báo cáo, kê khai. Chính vì thế mà extension này được xây dựng nên để cung cấp cho bạn tính năng chuyển đổi số sang chữ số một cách đơn giản nhất và có thể tái sử dụng trên nhiều thuộc tính.

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

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

Cài đặt thông qua `composer` nếu như đó là một khái niệm mới với bạn xin click vào [đây](http://getcomposer.org/download/) để tìm hiểu nó.

```
composer require "yiiviet/yii2-n2w"
```

hoặc thêm

```
"yiiviet/yii2-n2w": "*"
```

vào phần `require` trong file composer.json.

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

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

Extension này là một `behavior` hổ trợ cho tất cả các `components` của `yii2`nên để sử dụng nó thì bạn phải khái báo nó vào bên trong phương thức `behaviors` của `component` (model, active record...).

Ví dụ:

```
/**
* @property int $amount
*/

class Order extends ActiveRecord {

    public function behaviors() {
        return [
            'n2w' => [
                'class' => 'yiiviet\n2w\Behavior',
                'property' => 'amount',
                'unit' => 'đồng'
            ]

        ];

    }

}

$order = Order::findOne(1);

print $order->amount; // 100000
print $order->amountFormat; // Một trăm ngàn đồng
```

Như bạn thấy sau khi khai báo attribute `amount` vào `property` thì ngay lập tức bạn có thể sử dụng attribute `amountFormat` để chuyển đổi số sang chữ số mà không cần khai báo gì thêm.

Cách khai báo nhiều thuộc tính cùng lúc:

```
/**
* @property int $amount
* @property int $tax
*/

class Order extends ActiveRecord {

    public function behaviors() {
        return [
            'n2w' => [
                'class' => 'yiiviet\n2w\Behavior',
                'properties' => ['amount', 'tax'],
                'unit' => 'đồng'
            ]

        ];

    }

}

$order = Order::findOne(1);

print $order->amount; // 100000
print $order->amountFormat; // Một trăm ngàn đồng

print $order->tax; // 10000
print $order->taxFormat; // Mười ngàn đồng
```

Nếu như bạn muốn sửa `suffix` thành một chuỗi khác thì khai báo như sau:

```
/**
* @property int $amount
* @property int $tax
*/

class Order extends ActiveRecord {

    public function behaviors() {
        return [
            'n2w' => [
                'class' => 'yiiviet\n2w\Behavior',
                'properties' => ['amount', 'tax'],
                'unit' => 'đồng',
                'suffix' => 'Convert'
            ]

        ];

    }

}

$order = Order::findOne(1);

print $order->amount; // 100000
print $order->amountConvert; // Một trăm ngàn đồng

print $order->tax; // 10000
print $order->taxConvert; // Mười ngàn đồng
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

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

2953d 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-wordsyii2yii2-extensionyiivietyii2extensionBehaviorn2wnumber to words

### Embed Badge

![Health badge](/badges/yiiviet-yii2-n2w/health.svg)

```
[![Health](https://phpackages.com/badges/yiiviet-yii2-n2w/health.svg)](https://phpackages.com/packages/yiiviet-yii2-n2w)
```

###  Alternatives

[sjaakp/yii2-taggable

Manage tags of ActiveRecord in Yii2.

2931.8k](/packages/sjaakp-yii2-taggable)[mdmsoft/yii2-autonumber

Auto number extension for the Yii framework

1831.2k](/packages/mdmsoft-yii2-autonumber)[valentinek/yii2-closure-table-behavior

This extension allows you to get functional for closure table trees.

1615.4k](/packages/valentinek-yii2-closure-table-behavior)[v0lume/yii2-meta-tags

DB based model meta data for SEO

194.1k](/packages/v0lume-yii2-meta-tags)

PHPackages © 2026

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