PHPackages                             jderusse/format - 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. jderusse/format

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

jderusse/format
===============

Simple function to format strings

1.0.0(9y ago)016MITPHPPHP &gt;=5.3.0

Since Dec 16Pushed 9y ago1 watchersCompare

[ Source](https://github.com/jderusse/format)[ Packagist](https://packagist.org/packages/jderusse/format)[ RSS](/packages/jderusse-format/feed)WikiDiscussions master Synced 3w ago

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

\# Format

`Format` provide the ability to do variable substitutions.

\## Installation

```
composer require jderusse/format

```

Usage
-----

[](#usage)

```
format('Hello {who}', ['who' => 'World']);
```

Usecase
-------

[](#usecase)

```
throw new \Exception(format('Fail to load resource "{resource}".', ['resource' => $fileName]);
```

```
$this->addFlash(format('Project "{name}" succesfully created.', ['name' => $project->getName()]);
```

Why?
----

[](#why)

Because I'm not happy with language alternatives.

```
- echo 'Should I use "'."'".'" or "'.'"'.'"';
+ echo format('Should I use "{single}" or "{double}"', ['single'=> "'", 'double' => '"']);
```

```
- sprintf('%s likes when %s repeat the same things', $user, $user');
+ format('{user} like when {user} repeat the same things', ['user'=> $user]);
```

```
- sprintf('%s%s%s', $scheme, $host, $path');
+ format('{scheme}{host}{path}', ['scheme' => $scheme, 'host' => $host, 'path' => $path]);
```

```
- echo "Hello {$this->getUser()->getusername()}. Welcome in {$this->getProject()->getName()}":
+ echo format('Hello {user}. Welcome in {project}', ['user' => $this->getUser()->getusername(), 'project' => $this->getProject()->getName()]):
```

###  Health Score

25

—

LowBetter than 36% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

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

Unknown

Total

1

Last Release

3482d ago

### Community

Maintainers

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

---

Top Contributors

[![jderusse](https://avatars.githubusercontent.com/u/578547?v=4)](https://github.com/jderusse "jderusse (1 commits)")

---

Tags

stringformatsprintf

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/jderusse-format/health.svg)

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

###  Alternatives

[nette/utils

🛠 Nette Utils: lightweight utilities for string &amp; array manipulation, image handling, safe JSON encoding/decoding, validation, slug or strong password generating etc.

2.1k417.9M1.7k](/packages/nette-utils)[willdurand/negotiation

Content Negotiation tools for PHP provided as a standalone library.

1.4k126.6M193](/packages/willdurand-negotiation)[coduo/php-to-string

Simple library that converts PHP value into strings

26913.1M13](/packages/coduo-php-to-string)[opis/string

Multibyte strings as objects

7424.5M8](/packages/opis-string)[hallindavid/manny

a package of manipulators that hopefully come in useful for those of us who always forget regex when we need it (manny is short for manipulation)

37106.7k3](/packages/hallindavid-manny)[icecave/repr

A library for generating string representations of any value, inspired by Python's reprlib library.

277.5M4](/packages/icecave-repr)

PHPackages © 2026

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