Download the PHP package t-labs-co/formatter without Composer
On this page you can find all versions of the php package t-labs-co/formatter. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download t-labs-co/formatter
More information about t-labs-co/formatter
Files in t-labs-co/formatter
Package formatter
Short Description A powerful data formatting package for Laravel — apply chainable format rules to transform, clean, and normalize data values.
License MIT
Homepage https://github.com/T-Labs-Co/formatter
Informations about the package formatter
t-labs-co/formatter
A powerful data formatting package for Laravel — apply chainable format rules to transform, clean, and normalize data values.
Features
- Simple and intuitive syntax for defining formatting rules
- 24+ built-in formatting rules (trim, replace, limit, date_format, etc.)
- Chainable rules using pipe
|separator - Custom formatting rules via
FormatterRuleabstract class - Facade support for convenient usage
- Full strict typing (PHPStan Level 8)
- Comprehensive test coverage
PHP and Laravel Version Support
| Package Version | PHP | Laravel |
|---|---|---|
| ^2.0 | ^8.4 | ^12 | ^13 |
| ^1.0 | ^8.2 | ^11 | ^12 |
Installation
Upgrading from v1.x? Read the Migration Guide for a step-by-step upgrade path.
Usage
Basic Usage
Using the Facade
Single Value Formatting
Custom Format Rules
Format Rules Reference
| Rule | Description | Example |
|---|---|---|
boolean |
Convert to boolean (true/false) | boolean or boolean:0 for 1/0 |
integer |
Convert to integer | integer |
float |
Convert to float | float |
pricing |
Format as pricing number | pricing:2 |
array |
Convert to array | array |
substring |
Extract substring | substring:0,5 or substring:from,to |
trim |
Trim whitespace | trim or trim:.,! |
trimstart |
Trim leading whitespace | trimstart |
trimend |
Trim trailing whitespace | trimend |
trimcustom |
Custom trim | trimcustom |
replace |
Case-insensitive string replace | replace:old,new |
replacefirst |
Replace first occurrence | replacefirst:old,new |
replacelast |
Replace last occurrence | replacelast:old,new |
studly |
Convert to StudlyCase | studly |
title |
Convert to Title Case | title |
upper |
Convert to UPPER CASE | upper |
lower |
Convert to lower case | lower |
md5 |
Generate MD5 hash | md5 |
limit |
Limit string length | limit:50 or limit:50,-- |
pad |
Pad both sides | pad:10,* |
padleft |
Pad left side | padleft:10,* |
padright |
Pad right side | padright:10,* |
date |
Validate and format date | date |
date_format |
Format date to specific format | date_format:Y-m-d |
timestamp |
Convert to Unix timestamp | timestamp |
url_param |
Extract URL query parameter | url_param:page |
Quality & Development Practices
- PHPStan Level 8 — Static analysis with maximum strictness
- Laravel Pint — Code style following Laravel conventions
- Pest PHP — Modern, elegant testing framework
- Strict Types — All source files use
declare(strict_types=1)
Testing
Changelog
Please see CHANGELOG for more information on what has changed recently.
Upgrade Guide
Please see MIGRATION for instructions on upgrading from v1.x to v2.0.
Contributing
Please see CONTRIBUTING for details.
Security Vulnerabilities
Please review our security policy on how to report security vulnerabilities.
Credits
- Ty Huynh
- All Contributors
License
The MIT License (MIT). Please see License File for more information.