PHPackages                             vdhicts/replacer - 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. vdhicts/replacer

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

vdhicts/replacer
================

Package to easily replace values in text for templating purposes.

v4.0.0(1mo ago)02871MITPHPPHP ^8.2CI failing

Since Feb 19Pushed 1mo agoCompare

[ Source](https://github.com/vdhicts/replacer)[ Packagist](https://packagist.org/packages/vdhicts/replacer)[ RSS](/packages/vdhicts-replacer/feed)WikiDiscussions main Synced 3d ago

READMEChangelog (4)Dependencies (5)Versions (6)Used By (0)

Replacer
========

[](#replacer)

This package allows you to easily replace values in text for templating purposes, like email messages from the database.

Requirements
------------

[](#requirements)

This package requires PHP 8.2+.

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

[](#installation)

Install the package with composer:

`composer require vdhicts/replacer`

Usage
-----

[](#usage)

```
$text = 'Hello [USERNAME]!';
$data = [
    'username' => 'World'
];

$replacer = new Replacer();
$replacer->process($text, $data);
```

### Custom delimiters

[](#custom-delimiters)

When initialising the `Replacer`, custom delimiters can be provided.

```
$text = 'Hello %USERNAME#!';
$data = [
    'username' => 'World'
];

$replacer = new Replacer('%', '#');
$replacer->process($text, $data);
```

The delimiters can also be provided after initialising:

```
$replacer
    ->setOpenDelimiter('%')
    ->setCloseDelimiter('#');
```

Tests
-----

[](#tests)

Full code coverage unit tests are available in the tests folder. Run via phpunit:

`vendor\bin\phpunit`

By default a coverage report will be generated in the build/coverage folder.

Contribution
------------

[](#contribution)

Any contribution is welcome, but it should be fully tested, meet the PSR-2 standard and please create one pull request per feature. In exchange you will be credited as contributor on this page.

Security
--------

[](#security)

If you discover any security related issues in this or other packages of Vdhicts, please email instead of using the issue tracker.

License
-------

[](#license)

This package is open-sourced software licensed under the [MIT license](http://opensource.org/licenses/MIT)

###  Health Score

51

—

FairBetter than 96% of packages

Maintenance89

Actively maintained with recent releases

Popularity12

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity79

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

Every ~983 days

Total

4

Last Release

57d ago

Major Versions

1.0.0 → 2.0.02019-12-11

2.0.0 → 3.0.02021-09-14

3.0.0 → v4.0.02026-03-18

PHP version history (3 changes)1.0.0PHP ~7.0

3.0.0PHP ^7.4|^8.0

v4.0.0PHP ^8.2

### Community

Maintainers

![](https://www.gravatar.com/avatar/88d23e7b707d1cfe0eea91c00590613f45e0c75cb0a3ce89354328332e5c0c02?d=identicon)[vdhicts](/maintainers/vdhicts)

---

Top Contributors

[![dvdheiden](https://avatars.githubusercontent.com/u/90568118?v=4)](https://github.com/dvdheiden "dvdheiden (17 commits)")

---

Tags

phpreplace

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan, Psalm

Code StyleECS

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vdhicts-replacer/health.svg)

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

###  Alternatives

[mustache/mustache

A Mustache implementation in PHP.

3.3k44.6M291](/packages/mustache-mustache)[roots/acorn

Framework for Roots WordPress projects built with Laravel components.

9682.1M97](/packages/roots-acorn)[whitecube/nova-flexible-content

Flexible Content &amp; Repeater Fields for Laravel Nova.

8053.0M25](/packages/whitecube-nova-flexible-content)[mopa/bootstrap-bundle

Easy integration of twitters bootstrap into symfony2

7042.9M33](/packages/mopa-bootstrap-bundle)[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3871.2M](/packages/limenius-react-bundle)[nicmart/string-template

StringTemplate is a very simple string template engine for php. I've written it to have a thing like sprintf, but with named and nested substutions.

2101.7M30](/packages/nicmart-string-template)

PHPackages © 2026

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