PHPackages                             splashsky/modello - 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. splashsky/modello

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

splashsky/modello
=================

A simple, lightweight template compiler

v4.3.2(3y ago)15202[2 issues](https://github.com/splashsky/modello/issues)[2 PRs](https://github.com/splashsky/modello/pulls)MITPHP

Since Sep 2Pushed 3y ago2 watchersCompare

[ Source](https://github.com/splashsky/modello)[ Packagist](https://packagist.org/packages/splashsky/modello)[ Docs](https://sharkk.net)[ RSS](/packages/splashsky-modello/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (10)DependenciesVersions (12)Used By (0)

[![](https://camo.githubusercontent.com/5b41e0663807169b551cb7fcba5959c504e3959ae127ddd6996d94e8f7262f90/68747470733a2f2f692e696d6775722e636f6d2f785a4b735850692e6a7067)](https://camo.githubusercontent.com/5b41e0663807169b551cb7fcba5959c504e3959ae127ddd6996d94e8f7262f90/68747470733a2f2f692e696d6775722e636f6d2f785a4b735850692e6a7067)

 [![](https://camo.githubusercontent.com/bb74db9466f46cae33bd29d438253fb4a622bc66a0cf5c75b2e8733ed0386e0e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f73706c617368736b792f6d6f64656c6c6f3f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/bb74db9466f46cae33bd29d438253fb4a622bc66a0cf5c75b2e8733ed0386e0e/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f73706c617368736b792f6d6f64656c6c6f3f7374796c653d666f722d7468652d6261646765) [![](https://camo.githubusercontent.com/965edf999bb19c9d7113337e293f27c4d20b999a440531a46a3296371fb7c407/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d616465253230776974682d7068702d626c756576696f6c65743f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/965edf999bb19c9d7113337e293f27c4d20b999a440531a46a3296371fb7c407/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6d616465253230776974682d7068702d626c756576696f6c65743f7374796c653d666f722d7468652d6261646765)

Modello - simple, lightweight template compiler
===============================================

[](#modello---simple-lightweight-template-compiler)

**Modello** is a super-simple, super-lightweight templating engine written in PHP. It's purpose is to be a standalone class that can be included in any project and used to quickly and efficiently parse/compile a template.

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

[](#contributing)

While I don't intend for this to become a replacement for other templating solutions, I felt it would be fun to make a simple little compiler for small projects. The goal is ease of use and compactness, and hopefully my work reflects that.

If you have ideas, or want to contribute some code, feel more than welcome to open an Issue or a Pull Request. Thanks for dropping by!

Getting Started
---------------

[](#getting-started)

The easiest way of using Modello in your project is Composer.

```
composer require splashsky/modello
```

Otherwise, you can download the `.zip` or clone the project using Git. After that, move the `Modello.php` class file to wherever you want!

How do I start up the compiler?
-------------------------------

[](#how-do-i-start-up-the-compiler)

Modello is easy to get started with.

```
// require() and/or 'use' Modello, depending on your environment
$modello = new Modello('path/to/views', 'path/to/cache');
```

The first argument for the constructor tells Modello where your template directory is, and this will be the root from which Modello looks for template files. The second argument tells Modello where to create the compiled views.

`$modello->setViews(string $viewPath)` and `$modello->setCache(string $cachePath)` are available to change the views and cache directories at runtime.

Using `$modello->setExtension(string $extension)` allows you to change the extension Modello looks for on template files - by default this is `.mllo.php`.

You can use `$modello->setCacheEnabled(bool $enabled)` to enable or disable caching - disabled means that Modello will re-compile the view on every render.

How do I compile a template?
----------------------------

[](#how-do-i-compile-a-template)

Simply call `$modello->view()`!

```
/**
 * File Directory
 * | cache/views/
 *   example.php (will be created at render)
 * | views/
 *   example.mllo.php
*/

echo $modello->view('example', ['foo' => 'bar']);
```

When telling Modello what template to render, ensure you're not adding the extension - only use the name of the template. Modello will use whatever extension it has set when it looks for your file. You can use dot notation as well, so 'foo.bar' is as valid as 'foo/bar'.

The second argument in the `view()` function is your data array - these `key => value` pairs will be extracted into the resulting template.

When a template is compiled for the first time - or if Modello detects the original template file has changed - it will generate a newly compiled version of the template and store it in the cached directory for faster subsequent renders.

What syntax can I use in the template?
--------------------------------------

[](#what-syntax-can-i-use-in-the-template)

Modello uses template syntax very similar (basically identical) to Laravel Blade. Here's the directives it currently supports:

```
// This is the echo syntax
{{ $foo }}
{{ bar() }}

// This is the if-else syntax
@if(condition)
    // ...
@elseif(condition)
    // ...
@else
    // ...
@endif

// This is the foreach syntax
@foreach($array as $key => $value)
    {{ $key }} equals {{ $value }}
@endforeach

// This is a comment
{{-- I won't show up in the HTML or in the compiled template file! --}}

// This is the almighty include directive!
@include('path.to.template')

// We also support blocks and yielding
@block('foo')
    something here
@endblock

@yield('foo') // Outputs: something here

// Add block conditionals
@hasblock('foo')
if block foo exists, this will be output!
@endif

@blockmissing('bar')
if the bar block doesn't exist, this will be put out!
@endif

```

As long as the data you provide the directives is valid PHP, it will work!

For the include directive, it will look for the template you specify relative to the template directory you gave to Modello. If it cannot find the template you specify, it will return "path/to/template.php could not be found", which will show up in your HTML.

What if I just need to parse?
-----------------------------

[](#what-if-i-just-need-to-parse)

Modello still has the classic parsing functionality from before - in the static method `parse()`.

```
echo Modello::parse('Hello, {{ name }}!', ['name' => 'Jerry']);
```

Of course, you won't have access to any of the directives or other features of a compiled template.

License
-------

[](#license)

Modello is completely free, open source software. It's covered under the MIT license, and you can read the details in the [license.md](license.md).

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity15

Limited adoption so far

Community9

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

Recently: every ~154 days

Total

10

Last Release

1141d ago

Major Versions

v1.2.5 → v3.0.02021-07-21

v3.2.3 → v4.0.02023-03-28

### Community

Maintainers

![](https://www.gravatar.com/avatar/21d2a3d664d9717c20fdbad24664fb850e2d543c7b0ab65cc1776ee52efa04e7?d=identicon)[Skylear](/maintainers/Skylear)

---

Top Contributors

[![splashsky](https://avatars.githubusercontent.com/u/12104206?v=4)](https://github.com/splashsky "splashsky (39 commits)")

---

Tags

compilerformatterlightweight-template-enginelightweight-templating-enginemodellophptemplatetemplate-engineparsertemplatecompilerengine

### Embed Badge

![Health badge](/badges/splashsky-modello/health.svg)

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

###  Alternatives

[latte/latte

☕ Latte: the intuitive and fast template engine for those who want the most secure PHP sites. Introduces context-sensitive escaping.

1.3k15.7M683](/packages/latte-latte)[anourvalar/office

Generate documents from existing Excel &amp; Word templates | Export tables to Excel (Grids)

24085.2k](/packages/anourvalar-office)[phug/phug

Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation

67292.2k13](/packages/phug-phug)[pyrocms/lex

A lightweight template parser.

11128.3k2](/packages/pyrocms-lex)[templavoilaplus/templavoilaplus

Building kit for custom pages and content elements with individual fields, containers and backend layouts. Supporting drag'n'drop and multiple references.

2637.6k13](/packages/templavoilaplus-templavoilaplus)

PHPackages © 2026

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