PHPackages                             mattferris/staccato - 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. mattferris/staccato

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

mattferris/staccato
===================

A minimalist template library for native PHP templates

v1.1.1(2y ago)018BSD-2-ClausePHP

Since Feb 28Pushed 1y ago1 watchersCompare

[ Source](https://github.com/mattferris/staccato)[ Packagist](https://packagist.org/packages/mattferris/staccato)[ RSS](/packages/mattferris-staccato/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)DependenciesVersions (8)Used By (0)

Staccato
========

[](#staccato)

Staccato is a minimalist templating system for native PHP templates.

It borrows foundational ideas from the venerable [Twig](https://twig.symfony.com "Twig - The flexible, fast, and secure
template engine for PHP"), primarily the inheritance model. As such, it's built on the concept of extending a template via *blocks*. Caching is provided as a first-class feature (though it's not required), with support for *dynamic* caching enabling a cached template to include dynamic content. A simple plugin facility ensures Staccato can be extended as needed. Staccato ships with an included markdown plugin that uses [Parsedown](https://parsedown.org/ "Parsedown - A Better Markdown Parser in PHP").

Inheritance
-----------

[](#inheritance)

Got something you've been wanting to get off your chest? Create a blog! Start by writing a simple site template called `base.tmpl.php`.

```

    The Frivolous Fancies of Feral Foxes

    The Frivolous Fancies of Foxes

```

There is a built-in variable called `$_` that refers to the instance of *Template*that represents the current template. It's use will be covered later.

Now we can render the template.

```
use MattFerris\Staccato\Staccato;

$vars = [
    'title' => 'Are Foxes Funny or Frightening?',
    'body' => '...';
];

echo (new Staccato())->render('base.tmpl.php', $vars);
```

Of course, everything we've done so far is bog-standard PHP templating and doesn't require a template engine. So let's make things interesting.

As you're readership has grown, you're noticing demand for specific types of content, like reviews and more formal articles in addition to the current informal posts. It's time to extend your template to create a distinct look for each type of content. *Blocks* makes this quite easy.

```

    The Frivolous Fancies of Feral Foxes

    The Frivolous Fancies of Foxes
