PHPackages                             ferryhopper/php-string-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. ferryhopper/php-string-formatter

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

ferryhopper/php-string-formatter
================================

A simple and configurable string formatting pipeline for PHP.

v0.1.0(9mo ago)14MITPHPPHP &gt;=7.1

Since Aug 7Pushed 9mo agoCompare

[ Source](https://github.com/ferryhopper/php-string-formatter)[ Packagist](https://packagist.org/packages/ferryhopper/php-string-formatter)[ RSS](/packages/ferryhopper-php-string-formatter/feed)WikiDiscussions main Synced 1mo ago

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

php-string-formatter
====================

[](#php-string-formatter)

A simple and configurable string formatting pipeline for PHP.

Define formatting rules using a compact, readable DSL like:

```
padLeft:10:0;replace:_:space;padAfterFirst:11:0

```

This library lets you manipulate strings in a declarative and reusable way — ideal for formatting ticket numbers, codes, IDs, or any value that needs structured transformation.

---

🚀 Installation
--------------

[](#-installation)

```
composer require ferryhopper/php-string-formatter
```

---

🧪 Usage
-------

[](#-usage)

```
use StringFormatter\StringFormatter;

$formatted = StringFormatter::apply('K563793', 'remove:space;replace:K:A;padAfterFirst:11:0');
// Returns: "K 00000563793"
```

---

🛠 Supported Formatters
----------------------

[](#-supported-formatters)

FormatterDescription`padLeft:length:char`Left-pads the string to `length` using `char`.`padRight:length:char`Right-pads the string to `length` using `char`.`replace:search:replace`Replaces all occurrences of `search` with `replace`.`remove:target`Removes all occurrences of `target`.`padAfterFirst:length:char`Pads the part after the first character to `length` using `char`.---

🔤 Special Keywords
------------------

[](#-special-keywords)

- Use `"space"` instead of a literal space character.
    - `replace:_:space` → replaces `_` with a space
    - `remove:space` → removes all spaces

---

🧪 Testing
---------

[](#-testing)

```
vendor/bin/phpunit
```

---

📦 Roadmap Ideas
---------------

[](#-roadmap-ideas)

- Custom formatter registration
- Support for named pipelines
- Optional error handling modes (fail-fast vs silent)

---

👨‍💻 Authors
-----------

[](#‍-authors)

Maintained by the [Ferryhopper](https://www.ferryhopper.com) engineering team.
Initial development by [@vlahanas](https://github.com/vlahanas).

---

📝 License
---------

[](#-license)

MIT — see [LICENSE](LICENSE) for details.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance57

Moderate activity, may be stable

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity21

Early-stage or recently created project

 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

284d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/09915beb7d3b44a9462e6060ab80279b72658dc779b08c270f9551f78de9ea5d?d=identicon)[vlahanas](/maintainers/vlahanas)

---

Top Contributors

[![vlahanas](https://avatars.githubusercontent.com/u/19361558?v=4)](https://github.com/vlahanas "vlahanas (10 commits)")

---

Tags

phpformatterstringDSLconfigurablepipeline

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/ferryhopper-php-string-formatter/health.svg)

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

###  Alternatives

[coduo/php-to-string

Simple library that converts PHP value into strings

27112.7M10](/packages/coduo-php-to-string)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2516.7k](/packages/iteks-laravel-enum)

PHPackages © 2026

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