PHPackages                             lorenzosanzari/mozaiku - 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. lorenzosanzari/mozaiku

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

lorenzosanzari/mozaiku
======================

Plain PHP Template Inheritance Class

v1.0.1(6y ago)19MITPHPPHP &gt;=5.6.0

Since Oct 19Pushed 6y ago2 watchersCompare

[ Source](https://github.com/lorenzosanzari/mozaiku)[ Packagist](https://packagist.org/packages/lorenzosanzari/mozaiku)[ RSS](/packages/lorenzosanzari-mozaiku/feed)WikiDiscussions master Synced today

READMEChangelog (2)DependenciesVersions (4)Used By (0)

[![Mozaiku logo](logo.svg)](logo.svg)

Mozaiku
=======

[](#mozaiku)

Plain PHP Template Inheritance
------------------------------

[](#plain-php-template-inheritance)

Inspired by several hierarchical template engines like Twig or Blade, Mozaiku offers to you the possibility of building hierarchical templates using simply **plain PHP** language. It is a very simple and lightweight class, with very small footprint.

License
=======

[](#license)

Mozaiku is released under the [MIT](https://opensource.org/licenses/MIT) license.

Install via Composer
====================

[](#install-via-composer)

If you are using [Composer](https://getcomposer.org/), you can run the following command:

```
composer require lorenzosanzari/mozaiku

```

OR you can [download](https://github.com/lorenzosanzari/mozaiku/archive/master.zip) the zip file directly from Github and extract them to your web directory.

Template inheritance
====================

[](#template-inheritance)

What is template inheritance? Template inheritance is an elegant way to make and compose reusable HTML layouts in a web application. It is much more powerful than traditional "include" (bad) practice (like include a header and footer file).

With Mozaiku, you can implement template inheritance simply using plain PHP language. There is no need to learn another template language.

Having a main template, you can conceptually define a "child" view that extends the main layout. This means that it will have the same general appearance as the layout, but will redefine some sections with its own content. In other words, in the child view, you only need to redefine the sections you want to change with respect to the theme (section override) and the whole page will inherit all the rest of the content from the "parent" theme.

Sections
========

[](#sections)

In a layout, you can define a new section simply by writing:

```
