PHPackages                             aesonus/message-templates - 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. aesonus/message-templates

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

aesonus/message-templates
=========================

A small library designed to render partials for use as messages

v1.0(6y ago)024MITPHP

Since Apr 2Pushed 6y agoCompare

[ Source](https://github.com/Aesonus/message-templates)[ Packagist](https://packagist.org/packages/aesonus/message-templates)[ RSS](/packages/aesonus-message-templates/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (6)Dependencies (1)Versions (8)Used By (0)

Message Templates
=================

[](#message-templates)

This library contains some classes to help with rendering messages and other templates to the user.

Usage
-----

[](#usage)

This package has many uses and is very versatile. Let's take a look.

### Template Sources

[](#template-sources)

Template sources are used to provide the rendering object information about the template.

Let's look at an example

##### Set up array to source from

[](#set-up-array-to-source-from)

In this example, we will use a global constant to source the templates from

```
const TEMPLATES = [
   'key1' => 'template string, %s',
   'key2' => 'template string two, %s',
];
```

##### Implement the message source interfaces

[](#implement-the-message-source-interfaces)

We will create a new class for each potential key that will inherit the getTemplate method from an abstract base class. This is to ensure that each template will be represented by a discreet class which will return the correct template from the same source.

```
abstract class ConstTemplateSource implements TemplateSourceInterface
{
    public function getTemplate(): string
    {
        return TEMPLATES[$this->key];
    }
}
```

```
class Key1 extends ConstTemplateSource {
    protected $key = 'key1';
}
```

```
class Key2 extends ConstTemplateSource {
    protected $key = 'key2';
}
```

### Template Rendering

[](#template-rendering)

Templates are rendered using classes that implement the RenderTemplateInterface.

Adding on to the previous example, we will use the included RenderVsprintfTemplate class

```
// Create the render object
$template = new RenderVsprintfTemplate();

// Set the template source for the render object
$template->setSource(new Key1);

//Output the template with data
echo $template->render(['purple']);

//Outputs: template string, purple

// Set another template source for the render object
$template->setSource(new Key2);

//Output the template with data
echo $template->render(['red']);

//Outputs: template string two, red
```

#### Other rendering implementations

[](#other-rendering-implementations)

Many other rendering implementations can be created using the RenderTemplateInterface. This can allow for using engines like Twig to render templates using the same sources or even setting variables in other classes to a rendered template.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity61

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 ~1 days

Total

7

Last Release

2228d ago

Major Versions

v0.2.1 → v1.02020-04-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/c43cc8496d84b0c76ac9c62092cc312302a83fbb4558e8e8d1761fe8c9e049bd?d=identicon)[Aesonus](/maintainers/Aesonus)

---

Top Contributors

[![Aesonus](https://avatars.githubusercontent.com/u/24643115?v=4)](https://github.com/Aesonus "Aesonus (12 commits)")

### Embed Badge

![Health badge](/badges/aesonus-message-templates/health.svg)

```
[![Health](https://phpackages.com/badges/aesonus-message-templates/health.svg)](https://phpackages.com/packages/aesonus-message-templates)
```

###  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)
