PHPackages                             azbosakov/param-string-printf - 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. [Templating &amp; Views](/categories/templating)
4. /
5. azbosakov/param-string-printf

ActiveLibrary[Templating &amp; Views](/categories/templating)

azbosakov/param-string-printf
=============================

Template string with printf-style placeholders.

1.0.0(7y ago)011MITPHP

Since Mar 13Pushed 7y agoCompare

[ Source](https://github.com/AZBosakov/param-string-printf)[ Packagist](https://packagist.org/packages/azbosakov/param-string-printf)[ RSS](/packages/azbosakov-param-string-printf/feed)WikiDiscussions master Synced 5d ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

Class description
=================

[](#class-description)

Template string with printf-style placeholders.

When using sprintf(), the template parameters are passed as arguments. This class is sort of "delayed sprintf" - instead of variables, parameter names are passed to the constructor. There must be enough parameter names for all placeholders.

Example
=======

[](#example)

```
use AZBosakov\ParamString\Printf;
...
$pf = new Printf('The answer is %d, the question is %s, the answer again is %d', 'ans', 'q', 'ans');
$pf = $pf->withParams(['ans'=>42, 'q'=>'"6 x 9 = ?"']);

"$pf" == "The answer is 42, the question is "6 x 9 = ?", the answer again is 42";

```

Methods
=======

[](#methods)

public function \_\_construct(string $template, string ...$paramNames)
----------------------------------------------------------------------

[](#public-function-__constructstring-template-string-paramnames)

There must be enough params for all placeholders.

public function getTemplate() : string (ParamStringInterface)
-------------------------------------------------------------

[](#public-function-gettemplate--string-paramstringinterface)

Get the template string passed to the constructor

public function withParam(string $name, $value) : self (ParamStringInterface)
-----------------------------------------------------------------------------

[](#public-function-withparamstring-name-value--self-paramstringinterface)

Clone the object and set the named param value.

public function getParam(string $name) (ParamStringInterface)
-------------------------------------------------------------

[](#public-function-getparamstring-name-paramstringinterface)

Get a parameter by name

public function withParams(array $params) : self (ParamStringInterface)
-----------------------------------------------------------------------

[](#public-function-withparamsarray-params--self-paramstringinterface)

Clone the object and set multiple params at once.

public function getParams() : array (ParamStringInterface)
----------------------------------------------------------

[](#public-function-getparams--array-paramstringinterface)

Get a snapshot of the parameters

public function \_\_toString() : string (ParamStringInterface)
--------------------------------------------------------------

[](#public-function-__tostring--string-paramstringinterface)

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity60

Established project with proven stability

 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

2622d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9fe6053e1652840db4fa7c442c597345a10f0ea26276bfa2e732bbb32b7c519d?d=identicon)[azbosakov](/maintainers/azbosakov)

---

Top Contributors

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

---

Tags

templatetemplatingsprintfprintf

### Embed Badge

![Health badge](/badges/azbosakov-param-string-printf/health.svg)

```
[![Health](https://phpackages.com/badges/azbosakov-param-string-printf/health.svg)](https://phpackages.com/packages/azbosakov-param-string-printf)
```

###  Alternatives

[eftec/bladeone

The standalone version Blade Template Engine from Laravel in a single php file

8208.4M87](/packages/eftec-bladeone)[fenom/fenom

Fenom - excellent template engine for PHP

44395.5k19](/packages/fenom-fenom)[duncan3dc/blade

Use Laravel Blade templates without the full Laravel framework

160499.5k24](/packages/duncan3dc-blade)[eftec/bladeonehtml

The standalone version Blade Template Engine from Laravel in a single php file

1018.1k5](/packages/eftec-bladeonehtml)

PHPackages © 2026

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