PHPackages                             crisu83/yii-formatter - 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. [Templating &amp; Views](/categories/templating)
4. /
5. crisu83/yii-formatter

ActiveYii-extension[Templating &amp; Views](/categories/templating)

crisu83/yii-formatter
=====================

A collection of formatters for the Yii PHP framework.

107.7k11PHP

Since May 22Pushed 13y ago2 watchersCompare

[ Source](https://github.com/Crisu83/yii-formatter)[ Packagist](https://packagist.org/packages/crisu83/yii-formatter)[ RSS](/packages/crisu83-yii-formatter/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependenciesVersions (1)Used By (1)

yii-formatter
=============

[](#yii-formatter)

A collection of formatters for the Yii PHP framework.

Setup
-----

[](#setup)

In order to start using the formatters you need to configure it for your application.

```
'components' => array(
    'format' => array(
        'class' => 'path.to.Formatter',
        'formatters' => array(), // global formatter configurations (name=>config)
    ),
),
```

Usage
-----

[](#usage)

Once you have configured the formatted you can use it by calling the format component.

```
Yii::app()->format->boolean($published);
Yii::app()->format->currency($price, array('currency' => 'EUR'));
Yii::app()->format->dateTime($updatedAt, array('dateWidth' => 'short', 'timeWidth' => 'short');
Yii::app()->format->runFormatter('path.to.MyFormatter', 'foo');
Yii::app()->format->inline(array($this, 'myFormattingMethod'), 'bar');
```

### Formatting model attributes

[](#formatting-model-attributes)

To allow for formatting model attributes easily you can attach the formatter behavior to your model.

```
function behaviors() {
  return array(
    'formatter' => array(
      'class' => 'path.to.FormatterBehavior',
      'formatters' => array(), // component formatter configurations (name=>config)
    ),
  );
}
```

When the behavior is attached you can call it to format any attribute value using a formatter.

```
$model->formatAttribute('boolean', 'published');
$model->formatAttribute('currency', 'price', array('price' => 'EUR'));
$model->formatAttribute('dateTime', 'updatedAt', array('dateWidth' => 'short', 'timeWidth' => 'short'));
$model->formatAttribute('path.to.MyFormatter', 'foo');
$model->formatAttribute('myFormattingMethod', 'bar');
```

You can also write your own formatters or use inline methods for formatting attribute values if necessary.

###  Health Score

27

—

LowBetter than 47% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity41

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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/ab3becb3323ceb956c661f3e6ef4312dcd00ec4ba03d1bba5fcef793f5c4286d?d=identicon)[crisu83](/maintainers/crisu83)

---

Top Contributors

[![cniska](https://avatars.githubusercontent.com/u/1044868?v=4)](https://github.com/cniska "cniska (22 commits)")

### Embed Badge

![Health badge](/badges/crisu83-yii-formatter/health.svg)

```
[![Health](https://phpackages.com/badges/crisu83-yii-formatter/health.svg)](https://phpackages.com/packages/crisu83-yii-formatter)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

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