PHPackages                             michael-rubel/laravel-formatters - 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. michael-rubel/laravel-formatters

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

michael-rubel/laravel-formatters
================================

This package is a collection of classes you can use to standardize data formats in your Laravel application. It uses the Service Container to easily extend or override the formatter classes.

8.0.2(1y ago)9494.1k↓31%7[2 PRs](https://github.com/michael-rubel/laravel-formatters/pulls)4MITPHPPHP ^8.1CI failing

Since Oct 30Pushed 1y ago1 watchersCompare

[ Source](https://github.com/michael-rubel/laravel-formatters)[ Packagist](https://packagist.org/packages/michael-rubel/laravel-formatters)[ Docs](https://github.com/michael-rubel/laravel-formatters)[ Fund](https://paypal.com/donate/?hosted_button_id=KHLEL8PFS4AXJ)[ RSS](/packages/michael-rubel-laravel-formatters/feed)WikiDiscussions main Synced yesterday

READMEChangelog (10)Dependencies (10)Versions (51)Used By (4)

[![Laravel Formatters](https://user-images.githubusercontent.com/37669560/176375794-5588c598-858a-4fd7-a182-7094e219c788.png)](https://user-images.githubusercontent.com/37669560/176375794-5588c598-858a-4fd7-a182-7094e219c788.png)

Laravel Formatters
==================

[](#laravel-formatters)

[![Latest Version on Packagist](https://camo.githubusercontent.com/975c6d5531c88956aaa64a4645ac485eba974cca3f4d458698d898660714b880/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d69636861656c2d727562656c2f6c61726176656c2d666f726d6174746572732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7061636b6167697374)](https://packagist.org/packages/michael-rubel/laravel-formatters)[![Total Downloads](https://camo.githubusercontent.com/677f53ad54fa9e93a9e95097c0ec7b6884982ee495e9fc61695ca6ac58f0703c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d69636861656c2d727562656c2f6c61726176656c2d666f726d6174746572732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7061636b6167697374)](https://packagist.org/packages/michael-rubel/laravel-formatters)[![Code Quality](https://camo.githubusercontent.com/b1091f6a32be45fc236232e95d385f9c01db8bcdbfebbd7834b7a1f1289a4f61/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f7175616c6974792f672f6d69636861656c2d727562656c2f6c61726176656c2d666f726d6174746572732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/michael-rubel/laravel-formatters/?branch=main)[![Code Coverage](https://camo.githubusercontent.com/b4d8cbf232b5c39a53dd4d4c02f4961684afb1e3e2418a049624500cb83c0012/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f6d69636861656c2d727562656c2f6c61726176656c2d666f726d6174746572732e7376673f7374796c653d666c61742d737175617265266c6f676f3d7363727574696e697a6572)](https://scrutinizer-ci.com/g/michael-rubel/laravel-formatters/?branch=main)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0d61cf1929289242a6c6584b0338a612aaef15cd44884e6a93374009ef3bfd26/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d69636861656c2d727562656c2f6c61726176656c2d666f726d6174746572732f72756e2d74657374732e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d7465737473266c6f676f3d676974687562)](https://github.com/michael-rubel/laravel-formatters/actions)[![PHPStan](https://camo.githubusercontent.com/1d06ef6100f72b187004a07364964c8e82277e9771311579aa847fc4bb7127a9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f6d69636861656c2d727562656c2f6c61726176656c2d666f726d6174746572732f7068707374616e2e796d6c3f6272616e63683d6d61696e267374796c653d666c61742d737175617265266c6162656c3d6c6172617374616e266c6f676f3d6c61726176656c)](https://github.com/michael-rubel/laravel-formatters/actions)

This package introduces the `Formatter` pattern you can use to standardize data formats in your Laravel application. You can write your own formatters and put them in `app/Formatters` folder, then apply them everywhere in your application through `format` helper. The package uses the Service Container under the hood to easily extend or override the formatter classes.

---

The package requires `PHP 8.1` or higher and `Laravel 10` or higher. If you're looking for older versions, check [release history](https://github.com/michael-rubel/laravel-formatters/releases).

\#StandWithUkraine
------------------

[](#standwithukraine)

[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)

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

[](#installation)

Install the package via composer:

```
composer require michael-rubel/laravel-formatters
```

```
php artisan vendor:publish --tag="formatters-config"
```

Usage
-----

[](#usage)

```
format(DateTimeFormatter::class, now());
```

You can use a shorter version of the string as an alternative:

```
format('date-time', now());
```

Available built-in formatters
-----------------------------

[](#available-built-in-formatters)

- [`Date`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/DateFormatter.php)
- [`DateTime`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/DateTimeFormatter.php)
- [`FullName`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/FullNameFormatter.php)
- [`LocaleNumber`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/LocaleNumberFormatter.php)
- [`MaskString`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/MaskStringFormatter.php)
- [`Name`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/NameFormatter.php)
- [`TableColumn`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/TableColumnFormatter.php)
- [`TaxNumber`](https://github.com/michael-rubel/laravel-formatters/blob/main/src/Collection/TaxNumberFormatter.php)

### Artisan command

[](#artisan-command)

To make the programmer's life easier, we also added the Artisan command. You can use `make:formatter` command to generate formatter classes. It will put the class with the given name into `app/Formatters` folder and auto-inject the stub.

### Extending formatters

[](#extending-formatters)

Since the formatters are resolved through the Service Container they can be easily overridden by extending bindings.

For example in your Service Provider:

```
$this->app->extend(DateTimeFormatter::class, function ($formatter) {
    $formatter->datetime_format = 'Y.m.d H:i';

    return $formatter;
});
```

### Adding custom/overriding package formatters

[](#adding-customoverriding-package-formatters)

To add a custom formatter you should create the class that implements the `MichaelRubel\Formatters\Formatter` interface and put it to the `app/Formatters` folder. You can put formatter with the same name as the package's to override the formatter from the package. You can customize the folder in the config file.

### Examples

[](#examples)

You can discover examples of the usage [here](https://github.com/michael-rubel/laravel-formatters/blob/main/docs/examples.md).

Contributing
------------

[](#contributing)

If you have written your own formatter and want to add it to this package, PRs are welcomed. But take care of the extendability of the formatter you want to make as built-in and remember to write tests for your use cases.

Testing
-------

[](#testing)

```
composer test
```

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance36

Infrequent updates — may be unmaintained

Popularity44

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity72

Established project with proven stability

 Bus Factor1

Top contributor holds 92.9% 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 ~24 days

Recently: every ~118 days

Total

47

Last Release

597d ago

Major Versions

3.3.3 → 4.0.02022-05-18

4.2.0 → 5.0.02022-09-06

5.0.0 → 6.0.02022-09-20

6.3.0 → 7.0.02022-11-14

7.1.1 → 8.0.02024-03-13

PHP version history (3 changes)1.0.0PHP ^8.0

2.0.0PHP ^8.0|^8.1

8.0.0PHP ^8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/9c060c69332d50a7cb290529ad84a7f216dec94d59950db7446dc93208787083?d=identicon)[michael-rubel](/maintainers/michael-rubel)

---

Top Contributors

[![michael-rubel](https://avatars.githubusercontent.com/u/37669560?v=4)](https://github.com/michael-rubel "michael-rubel (286 commits)")[![olsza](https://avatars.githubusercontent.com/u/12556170?v=4)](https://github.com/olsza "olsza (16 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![khalyomede](https://avatars.githubusercontent.com/u/15908747?v=4)](https://github.com/khalyomede "khalyomede (2 commits)")

---

Tags

formatterformattersformattinglaravellooking-for-contributorsphplaravelmichael-rubellaravel-formatters

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/michael-rubel-laravel-formatters/health.svg)

```
[![Health](https://phpackages.com/badges/michael-rubel-laravel-formatters/health.svg)](https://phpackages.com/packages/michael-rubel-laravel-formatters)
```

###  Alternatives

[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[codewithdennis/filament-select-tree

The multi-level select field enables you to make single selections from a predefined list of options that are organized into multiple levels or depths.

329530.5k29](/packages/codewithdennis-filament-select-tree)[worksome/exchange

Check Exchange Rates for any currency in Laravel.

124603.0k](/packages/worksome-exchange)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)[tarfin-labs/event-machine

Event-driven state machines for Laravel with event sourcing, type-safe context, and full audit trail.

199.4k](/packages/tarfin-labs-event-machine)[tapp/filament-form-builder

User facing form builder using Filament components

132.4k3](/packages/tapp-filament-form-builder)

PHPackages © 2026

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