PHPackages                             minicli/stencil - 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. minicli/stencil

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

minicli/stencil
===============

Dummy template generator

0.2.1(2y ago)53.5k—0%7MITPHPPHP &gt;=8

Since Jun 20Pushed 2y ago1 watchersCompare

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

READMEChangelog (3)Dependencies (3)Versions (6)Used By (7)

Stencil
=======

[](#stencil)

> **/ˈstɛns(ə)l/** (noun): a thin sheet of card, plastic, or metal with a pattern or letters cut out of it, used to produce the cut design on the surface below by the application of ink or paint through the holes.

**Minicli/Stencil** is a dummy content replacer useful for generating templates.

Stencils are like lightweight templates with no advanced functionality (so it's not an engine). It simply replaces placeholders with content set up in a string-indexed array or dictionary.

If you are looking for a templating system for front-end views, this is not it! Go check [Twig](https://twig.symfony.com/). Stencil is useful for generating skeleton content (such as to auto-generate classes, Markdown docs and other files following a certain structure).

Dependencies
------------

[](#dependencies)

Stencil is a tiny standalone library that has only testing dependencies.

Usage
-----

[](#usage)

### Within Minicli

[](#within-minicli)

If you want to use Stencil within a Minicli app, you should have a look at the [Minicli Stencil command](https://github.com/minicli/command-stencil) that contains a basic implementation of a command using Stencil to generate documents based on templates. Check that repo for usage instructions.

### Standalone

[](#standalone)

For more freedom to include Stencil on your codebase, install standalone Stencil via Composer:

```
composer require minicli/stencil
```

Set up a directory within your project to hold your stencils:

```
mkdir stencils
cd stencils
```

Create a new `.tpl` file with some variables:

```
#stencils/mytemplate.tpl

## This is my Template

My name is {{ name }} and I am a {{ description }}.
```

From your project, instantiate a new Stencil, passing along the stencils directory you set up. Then, call the `applyTemplate` method with an array containing your values:

```
