PHPackages                             novatorius/blueprint - 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. novatorius/blueprint

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

novatorius/blueprint
====================

Dynamically replaces placeholders within a template string

1.0.0(1y ago)259MITPHPPHP ^8.1CI passing

Since Oct 30Pushed 1y ago2 watchersCompare

[ Source](https://github.com/Novatorius/blueprint)[ Packagist](https://packagist.org/packages/novatorius/blueprint)[ Docs](https://github.com/novatorius/blueprint)[ RSS](/packages/novatorius-blueprint/feed)WikiDiscussions main Synced 1mo ago

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

Blueprint
=========

[](#blueprint)

A PHP library for dynamically replacing placeholders within a template string. This package processes text templates by allowing developers to define multiple sets of placeholders, each with specific start and end delimiters and associated values.

Table of Contents
-----------------

[](#table-of-contents)

- [Introduction](#introduction)
    - [What is a Blueprint?](#what-is-a-blueprint)
- [Installation](#installation)
- [Usage](#usage)
    - [Creating a Placeholder Definition](#creating-a-placeholder-definition)
    - [Processing Placeholder Definitions](#processing-placeholder-definitions)
- [License](#license)

Introduction
------------

[](#introduction)

When working with dynamic content, it's often necessary to define placeholders in a template string and replace them with real values based on specific rules. This library enables the use of a flexible, reusable structure for replacing placeholders, making template customization intuitive and efficient.

This library supports both a basic replacement method for long templates and a more efficient scanning method for short templates, allowing it to adapt based on performance needs.

### What is a Blueprint?

[](#what-is-a-blueprint)

In this library, a "blueprint" refers to a template string containing placeholders that follow specific start and end delimiters. These placeholders are substituted with values according to PlaceholderDefinition instances.

The BlueprintProcessor processes each placeholder definition, replacing placeholders until the entire blueprint is complete. This approach supports nested or recursive replacements by re-processing the blueprint until no further changes occur.

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

[](#installation)

You can install this package via Composer:

```
composer require novatorius/blueprint
```

Usage
-----

[](#usage)

This library uses two primary classes:

- **BlueprintProcessor**: Manages the placeholder processing for a given template.
- **PlaceholderDefinition**: Defines a set of placeholders with specific delimiters and values.

### Creating a Placeholder Definition

[](#creating-a-placeholder-definition)

The PlaceholderDefinition class defines:

- A starting delimiter
- An ending delimiter
- An associative array of placeholder values

Processing Placeholder Definitions
----------------------------------

[](#processing-placeholder-definitions)

Once you've created placeholder definitions, you can process them with BlueprintProcessor. This fluent interface allows you to chain multiple definitions for successive replacement.

```
use Novatorius\Blueprint\BlueprintProcessor;
use Novatorius\Blueprint\PlaceholderDefinition;

$definition = new PlaceholderDefinition('{', '}', [
    'name' => 'Alice',
    'day' => 'Monday'
]);

$alternativeDefinition = new PlaceholderDefinition('|*', '*|', [
    'name' => 'Alice',
    'day' => 'Monday'
]);

// Define your initial template (the "blueprint").
$template = "Hello, {name}! Today is |*day*|.";

// Process the template using the defined placeholders.
$processed = (new BlueprintProcessor($template))
    ->processDefinition($definition)
    ->processDefinition($alternativeDefinition)
    ->toString();

echo $processed; // Outputs: "Hello, Alice! Today is Monday."
```

For multiple definitions, processDefinitions can be called in sequence:

```
$template = "Hello, {name}! Today is %%day%%.";

$definition1 = new PlaceholderDefinition('{', '}', ['name' => 'Alice']);
$definition2 = new PlaceholderDefinition('%%', '%%', ['day' => 'Monday']);

$processed = (new BlueprintProcessor($template))
    ->processDefinition($definition1)
    ->processDefinition($definition2)
    ->toString();

echo $processed; // Outputs: "Hello, Alice! Today is Monday."
```

`BlueprintProcessor` implements PHP's [\_\_toString](https://www.php.net/manual/en/stringable.tostring.php) magic method, so it can be automatically cast into a string, as well.

```
$template = "Hello, {name}! Today is %%day%%.";

$definition1 = new PlaceholderDefinition('{', '}', ['name' => 'Alice']);
$definition2 = new PlaceholderDefinition('%%', '%%', ['day' => 'Monday']);

$processed = (new BlueprintProcessor($template))
    ->processDefinition($definition1)
    ->processDefinition($definition2);

echo $processed; // Outputs: "Hello, Alice! Today is Monday."
```

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance39

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity47

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

565d ago

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

![Health badge](/badges/novatorius-blueprint/health.svg)

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

###  Alternatives

[sybrew/the-seo-framework-extension-manager

A WordPress plugin that allows you to manage extensions for The SEO Framework.

8490.3k](/packages/sybrew-the-seo-framework-extension-manager)

PHPackages © 2026

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