PHPackages                             fyre/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. [Utility &amp; Helpers](/categories/utility)
4. /
5. fyre/formatter

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

fyre/formatter
==============

A formatting library.

v5.0.2(7mo ago)01233MITPHP

Since Jun 19Pushed 7mo ago1 watchersCompare

[ Source](https://github.com/elusivecodes/FyreFormatter)[ Packagist](https://packagist.org/packages/fyre/formatter)[ RSS](/packages/fyre-formatter/feed)WikiDiscussions main Synced 3w ago

READMEChangelog (10)Dependencies (7)Versions (26)Used By (3)

FyreFormatter
=============

[](#fyreformatter)

**FyreFormatter** is a free, open-source formatting library for *PHP*.

Table Of Contents
-----------------

[](#table-of-contents)

- [Installation](#installation)
- [Basic Usage](#basic-usage)
- [Methods](#methods)

Installation
------------

[](#installation)

**Using Composer**

```
composer require fyre/formatter

```

In PHP:

```
use Fyre\Utility\Formatter;
```

Basic Usage
-----------

[](#basic-usage)

- `$typeParser` is a [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser).
- `$config` is a [*Config*](https://github.com/elusivecodes/FyreConfig).

```
$formatter = new Formatter($typeParser, $config);
```

Default configuration options will be resolved from the "*App*" key in the [*Config*](https://github.com/elusivecodes/FyreConfig).

- `$options` is an array containing configuration options.
    - `defaultLocale` is a string representing the default locale, and will default to the system default.
    - `defaultTimeZone` is a string representing the default time zone, and will default to the system default.
    - `defaultCurrency` is a string representing the default currency, and will default to "*USD*".

```
$container->use(Config::class)->set('App', $options);
```

**Autoloading**

It is recommended to bind the *Formatter* to the [*Container*](https://github.com/elusivecodes/FyreContainer) as a singleton.

```
$container->singleton(Formatter::class);
```

Any dependencies will be injected automatically when loading from the [*Container*](https://github.com/elusivecodes/FyreContainer).

```
$formatter = $container->use(Formatter::class);
```

Methods
-------

[](#methods)

**Currency**

Format a value as a currency string.

- `$value` is a string or number representing the value to format.
- `$options` is an array containing formatting options.
    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.
    - `$currency` is a string representing the currency, and will default to the *Formatter* default currency.

```
$currency = $formatter->currency($value, $options);
```

**Date**

Format a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) as a date string.

- `$value` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).
- `$options` is an array containing formatting options.
    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.
    - `$timeZone` is a string representing the time zone, and will default to the *Formatter* default time zone.
    - `$format` is a string representing the format, and will default to the [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser) default date user format.

```
$date = $formatter->date($value, $options);
```

**Date/Time**

Format a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) as a date/time string.

- `$value` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).
- `$options` is an array containing formatting options.
    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.
    - `$timeZone` is a string representing the time zone, and will default to the *Formatter* default time zone.
    - `$format` is a string representing the format, and will default to the [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser) default datetime user format.

```
$datetime = $formatter->datetime($value, $options);
```

**Get Default Currency**

Get the default currency.

```
$defaultCurrency = $formatter->getDefaultCurrency();
```

**Get Default Locale**

Get the default locale.

```
$defaultLocale = $formatter->getDefaultLocale();
```

**Get Default Time Zone**

Get the default time zone.

```
$defaultTimeZone = $formatter->getDefaultTimeZone();
```

**Number**

Format a value as a number string.

- `$value` is a string or number representing the value to format.
- `$options` is an array containing formatting options.
    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.

```
$number = $formatter->number($value, $options);
```

**Percent**

Format a value as a percent string.

- `$value` is a string or number representing the value to format.
- `$options` is an array containing formatting options.
    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.

```
$percent = $formatter->percent($value, $options);
```

**Set Default Currency**

Set the default currency.

- `$currency` is a string representing the currency code.

```
$formatter->setDefaultCurrency($currency);
```

**Set Default Locale**

Set the default locale.

- `$locale` is a string representing the locale.

```
$formatter->setDefaultLocale($locale);
```

**Set Default Time Zone**

Set the default time zone.

- `$timeZone` is a string representing the time zone.

```
$formatter->setDefaultTimeZone($timeZone);
```

**Time**

Format a [*DateTime*](https://github.com/elusivecodes/FyreDateTime) as a time string.

- `$value` is a [*DateTime*](https://github.com/elusivecodes/FyreDateTime).
- `$options` is an array containing formatting options.
    - `$locale` is a string representing the locale, and will default to the *Formatter* default locale.
    - `$timeZone` is a string representing the time zone, and will default to the *Formatter* default time zone.
    - `$format` is a string representing the format, and will default to the [*TypeParser*](https://github.com/elusivecodes/FyreTypeParser) default time user format.

```
$time = $formatter->time($value, $options);
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance62

Regular maintenance activity

Popularity10

Limited adoption so far

Community12

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

Every ~51 days

Recently: every ~24 days

Total

25

Last Release

233d ago

Major Versions

v1.0 → v2.02023-07-22

v2.0.3 → v3.02024-06-02

v3.1.0 → v4.02024-11-17

v4.1.7 → v5.02025-10-25

### Community

Maintainers

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

---

Top Contributors

[![elusivecodes](https://avatars.githubusercontent.com/u/18050480?v=4)](https://github.com/elusivecodes "elusivecodes (25 commits)")

---

Tags

formaterphp

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

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

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

PHPackages © 2026

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