PHPackages                             ryangjchandler/f - 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. ryangjchandler/f

ActiveLibrary

ryangjchandler/f
================

Nicer string formatting for PHP, inspired by Rust, Python and others.

v1.0.0(1y ago)1639MITPHPCI passing

Since Mar 20Pushed 1y ago2 watchersCompare

[ Source](https://github.com/ryangjchandler/f)[ Packagist](https://packagist.org/packages/ryangjchandler/f)[ Docs](https://github.com/ryangjchandler/skeleton-php)[ RSS](/packages/ryangjchandler-f/feed)WikiDiscussions main Synced 1mo ago

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

`f`
===

[](#f)

`f()` is an alternative to string concatenation and PHP's [`sprintf()`](https://www.php.net/manual/en/function.sprintf.php) function. It takes inspiration from how Rust handles string formatting with the `format!()` macro.

It doesn't currently do everything that `sprintf()` does, but it does enough to be useful.

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

[](#installation)

You can install the package using Composer:

```
composer require ryangjchandler/f
```

Usage
-----

[](#usage)

Once installed, the package will provide a global `f()` function that you can start using straight away.

```
f('Hello, {}', 'Ryan');
```

If you've already got an `f()` function registered in the global namespace, or despise global helper functions, you can use the `RyanChandler\F\F` class instead.

```
use RyanChandler\F\F;

F::format('Hello, {}', 'Ryan');
```

### Placeholder Syntax

[](#placeholder-syntax)

The `{}` syntax you see above is known as a placeholder. This is where the arguments you pass to `f()` will be injected into the string.

PlaceholderDescriptionExampleResult`{}`References an argument based on the position of the placeholder in the format string.`f('Hello, {}. I am {}.', 'world', 'Ryan')``Hello, world. I am Ryan.``{2}`References the 3rd argument (0-based indexing).`f('{}, {}, {}, {2}', 1, 2, 3)``1, 2, 3, 3``{name}`References a named argument.`f('Hello, {name}', name: "Ryan")``Hello, Ryan``{:b}`Formats an integer as binary.`f('{:b}', 42)``101010``{:x}`Formats an integer as hexadecimal.`f('{:x}', 42)``2a``{:o}`Formats an integer as octal.`f('{:o}', 42)``52``{:>10}`Right-justifies the argument to a width of `10` using a single space.`f('{:>10}', 'Hello')``     Hello``{:10}`Right-justifies the argument to a width of `10` using a custom character `0`.`f('{:0>10}', '12345')``0000012345``{:0width$}`Right-justifies the argument to a width defined by the named argument `width`.`f('{:>width$}', 'Hello', width: 7)``  Hello`Contributing
------------

[](#contributing)

All contributions are appreciated and welcome. Please refer to the [CONTRIBUTING](./CONTRIBUTING.md) document for more information on how to contribute.

Credits
-------

[](#credits)

- [Ryan Chandler](https://github.com/ryangjchandler)
- All contributors

License
-------

[](#license)

This project is licensed under the [MIT license](./LICENSE). Please refer to the [LICENSE](./LICENSE) document for more information.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance46

Moderate activity, may be stable

Popularity15

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity37

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

416d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/568d485d441c691b0358b9091254a6a671fef8f76b73f28af1180ad568d142b2?d=identicon)[ryangjchandler](/maintainers/ryangjchandler)

---

Top Contributors

[![ryangjchandler](https://avatars.githubusercontent.com/u/41837763?v=4)](https://github.com/ryangjchandler "ryangjchandler (5 commits)")

###  Code Quality

TestsPest

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/ryangjchandler-f/health.svg)

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

###  Alternatives

[binaryk/laravel-restify

Laravel REST API helpers

651399.1k](/packages/binaryk-laravel-restify)[erag/laravel-disposable-email

A Laravel package to detect and block disposable email addresses.

226102.4k](/packages/erag-laravel-disposable-email)[erag/laravel-pwa

A simple and easy-to-use PWA (Progressive Web App) package for Laravel applications.

16083.3k](/packages/erag-laravel-pwa)[lunarstorm/laravel-ddd

A Laravel toolkit for Domain Driven Design patterns

17959.0k](/packages/lunarstorm-laravel-ddd)[dragon-code/codestyler

A tool to automatically fix Coding Style Standards issues by The Dragon Code.

291.8M16](/packages/dragon-code-codestyler)[botble/git-commit-checker

Check coding standard &amp; code syntax with Git pre-commit hook.

47186.4k1](/packages/botble-git-commit-checker)

PHPackages © 2026

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