PHPackages                             cleaniquecoders/placeholdify - 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. cleaniquecoders/placeholdify

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

cleaniquecoders/placeholdify
============================

A powerful and extendable placeholder replacement engine for Laravel templates with context mapping, custom formatters, and fluent API

1.1.0(3mo ago)41[4 PRs](https://github.com/cleaniquecoders/placeholdify/pulls)MITPHPPHP ^8.4CI passing

Since Oct 16Pushed 2mo agoCompare

[ Source](https://github.com/cleaniquecoders/placeholdify)[ Packagist](https://packagist.org/packages/cleaniquecoders/placeholdify)[ Docs](https://github.com/cleaniquecoders/placeholdify)[ GitHub Sponsors]()[ RSS](/packages/cleaniquecoders-placeholdify/feed)WikiDiscussions main Synced today

READMEChangelog (2)Dependencies (24)Versions (8)Used By (0)

Placeholdify
============

[](#placeholdify)

[![Latest Version on Packagist](https://camo.githubusercontent.com/91bc1c918378bde310a81f08a94b20e3a225a4e3d0a3d151f6a1a4247ef6aa56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f636c65616e69717565636f646572732f706c616365686f6c646966792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/placeholdify)[![GitHub Tests Action Status](https://camo.githubusercontent.com/0c2d613262f6ad8d7eea6442782eada5643e1f5159024a6d7d465468c13a8f34/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636c65616e69717565636f646572732f706c616365686f6c646966792f72756e2d74657374732e796d6c3f6272616e63683d6d61696e266c6162656c3d7465737473267374796c653d666c61742d737175617265)](https://github.com/cleaniquecoders/placeholdify/actions?query=workflow%3Arun-tests+branch%3Amain)[![GitHub Code Style Action Status](https://camo.githubusercontent.com/6e573e0613045cd2a86e4afed25be574e9e14c1f6a8545d2e7536ee0779c5c46/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f636c65616e69717565636f646572732f706c616365686f6c646966792f6669782d7068702d636f64652d7374796c652d6973737565732e796d6c3f6272616e63683d6d61696e266c6162656c3d636f64652532307374796c65267374796c653d666c61742d737175617265)](https://github.com/cleaniquecoders/placeholdify/actions?query=workflow%3A%22Fix+PHP+code+style+issues%22+branch%3Amain)[![Total Downloads](https://camo.githubusercontent.com/8965e7f6750636e18682abc495fc2c258322a9c6f5757bd71649a52f868aece7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f636c65616e69717565636f646572732f706c616365686f6c646966792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/placeholdify)[![License](https://camo.githubusercontent.com/e2dfae0aeef1c0ce156cdb23e3f39c23d73eb735f4ca8adf07b6d40b742b6ad4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f636c65616e69717565636f646572732f706c616365686f6c646966792e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/cleaniquecoders/placeholdify)

A powerful and extendable placeholder replacement engine for Laravel that makes working with dynamic templates a breeze. Perfect for generating letters, invoices, certificates, emails, and any document that requires dynamic content injection.

Features
--------

[](#features)

- 🎯 **Context-Aware** - Register reusable context mappings for your models
- 🎨 **Custom Formatters** - Built-in formatters for dates, currency, numbers, and easy custom formatter registration
- ⚡ **Lazy Evaluation** - Defer expensive operations until needed
- 🔧 **Template Modifiers** - Support inline formatting like `{amount|currency:USD}` or `{name|upper}`
- 🧩 **Extendable** - Easily create dedicated context classes for different document types
- 💬 **Fluent API** - Chainable methods for clean, readable code
- 🛡️ **Safe Defaults** - Built-in fallback values and error handling
- 📦 **Zero Dependencies** - Works with plain Laravel, no extra packages required

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

[](#installation)

```
composer require cleaniquecoders/placeholdify
```

Optionally, publish the config file:

```
php artisan vendor:publish --tag=placeholdify-config
```

Quick Start
-----------

[](#quick-start)

### Simple Replacement

[](#simple-replacement)

```
use CleaniqueCoders\Placeholdify\PlaceholderHandler;

$template = "Hello {name}, your order #{orderNo} totaling {amount} has been confirmed.";

$content = PlaceholderHandler::process($template, [
    'name' => 'John Doe',
    'orderNo' => '12345',
    'amount' => '$99.99'
]);

// Output: "Hello John Doe, your order #12345 totaling $99.99 has been confirmed."
```

### Fluent API

[](#fluent-api)

```
$handler = new PlaceholderHandler();

$content = $handler
    ->add('name', $user->name)
    ->addDate('today', now(), 'F j, Y')
    ->addFormatted('total', 1234.56, 'currency', 'MYR')
    ->replace($template);
```

### Using Contexts

[](#using-contexts)

```
// Register context once
$handler->registerContextMapping('user', [
    'name' => 'name',
    'email' => 'email',
    'role' => fn($user) => $user->roles->pluck('name')->join(', '),
]);

// Use anywhere
$content = $handler
    ->useContext('user', $user, 'customer')
    ->replace('Hello {customer.name}, your role is {customer.role}');
```

### Template Modifiers

[](#template-modifiers)

```
$template = "Student: {name|upper}, Amount: {fee|currency:MYR}, Date: {created_at|date:d/m/Y}";

$content = $handler
    ->add('name', 'john doe')
    ->add('fee', 150.50)
    ->add('created_at', now())
    ->replaceWithModifiers($template);

// Output: "Student: JOHN DOE, Amount: MYR 150.50, Date: 16/10/2025"
```

Template Classes
----------------

[](#template-classes)

Create dedicated template classes for complex scenarios:

```
use CleaniqueCoders\Placeholdify\PlaceholdifyBase;

class InvoiceTemplate extends PlaceholdifyBase
{
    protected function configure(): void
    {
        $this->handler->setFallback('N/A');
    }

    public function build($invoice): PlaceholderHandler
    {
        return $this->handler
            ->add('invoice_no', $invoice->invoice_number)
            ->addFormatted('total', $invoice->total, 'currency', 'MYR')
            ->addDate('invoice_date', $invoice->created_at, 'd/m/Y')
            ->useContext('customer', $invoice->customer, 'customer');
    }
}

// Usage
$template = new InvoiceTemplate();
$content = $template->generate($invoice, $templateContent);
```

Documentation
-------------

[](#documentation)

For comprehensive documentation, examples, and advanced usage:

- 📖 **[Complete Documentation](docs/index.md)** - Full documentation index
- 🚀 **[Basic Usage](docs/basic-usage.md)** - Learn the fundamentals
- 🎨 **[Formatters](docs/formatters.md)** - Built-in and custom formatters
- 🔄 **[Context System](docs/context-system.md)** - Reusable model mappings
- ⚡ **[Advanced Features](docs/advanced-features.md)** - Lazy evaluation, conditionals, and more
- 🏗️ **[Template Classes](docs/template-classes.md)** - Organize your template logic
- ⚙️ **[Configuration](docs/configuration.md)** - Customize default behavior
- 🛠️ **[Artisan Commands](docs/artisan-commands.md)** - Command-line tools
- 🌍 **[Real World Examples](docs/real-world-examples.md)** - Complete implementation examples
- 📚 **[API Reference](docs/api-reference.md)** - Complete method documentation

Testing
-------

[](#testing)

```
composer test
```

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information on what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security Vulnerabilities
------------------------

[](#security-vulnerabilities)

Please review [our security policy](../../security/policy) on how to report security vulnerabilities.

Credits
-------

[](#credits)

- [Nasrul Hazim Bin Mohamad](https://github.com/nasrulhazim)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

41

—

FairBetter than 87% of packages

Maintenance84

Actively maintained with recent releases

Popularity5

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 93.8% 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 ~165 days

Total

2

Last Release

95d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b57069d0f4b634f65eccc6e5d5848990e25968d45ec2cf46d626c6a4658f944b?d=identicon)[nasrulhazim.m](/maintainers/nasrulhazim.m)

---

Top Contributors

[![nasrulhazim](https://avatars.githubusercontent.com/u/10341422?v=4)](https://github.com/nasrulhazim "nasrulhazim (30 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (1 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (1 commits)")

---

Tags

laravelCleanique Codersplaceholdify

###  Code Quality

TestsPest

Static AnalysisPHPStan

Code StyleLaravel Pint

### Embed Badge

![Health badge](/badges/cleaniquecoders-placeholdify/health.svg)

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

###  Alternatives

[spatie/laravel-permission

Permission handling for Laravel 12 and up

12.9k102.4M1.4k](/packages/spatie-laravel-permission)[spatie/laravel-pdf

Create PDFs in Laravel apps

1.0k4.8M47](/packages/spatie-laravel-pdf)[dedoc/scramble

Automatic generation of API documentation for Laravel applications.

2.1k11.2M100](/packages/dedoc-scramble)[defstudio/telegraph

A laravel facade to interact with Telegram Bots

816333.3k3](/packages/defstudio-telegraph)[spatie/laravel-passkeys

Use passkeys in your Laravel app

471890.7k39](/packages/spatie-laravel-passkeys)[rawilk/profile-filament-plugin

Profile &amp; MFA starter kit for filament.

3914.6k](/packages/rawilk-profile-filament-plugin)

PHPackages © 2026

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