PHPackages                             pkj/minibase-plugin-twig - 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. pkj/minibase-plugin-twig

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

pkj/minibase-plugin-twig
========================

This plugins replaces the PHP templating engine with Twig. Great for those who likes twig.

022PHP

Since May 5Pushed 13y ago1 watchersCompare

[ Source](https://github.com/peec/minibase-plugin-twig)[ Packagist](https://packagist.org/packages/pkj/minibase-plugin-twig)[ RSS](/packages/pkj-minibase-plugin-twig/feed)WikiDiscussions master Synced today

READMEChangelogDependenciesVersions (1)Used By (0)

Twig Plugin for Minibase
========================

[](#twig-plugin-for-minibase)

Enables Twig based templates. Uses the same interface as Minibase offers for rendering normal PHP views. Also includes custom blocks, filters and functions to take the full out of Minibase. Easily do `Fragment caching`.

This plugin makes it possible to render `.twig` and `.html` files with the Twig templating engine. `.php` files will still get rendered by the default Minibase view rendering engine.

Install
-------

[](#install)

```
{
  "require":{
	     "pkj/minibase-plugin-twig": "dev-master"
	}
}
```

Setup
-----

[](#setup)

Setup global view path, we need to know where twig templates are located.

```
$mb->setConfig(MB::CFG_VIEWPATH, __DIR__ . '/views');
```

Init the plugin

```
$mb->initPlugins(array(
	'Pkj\Minibase\Plugin\TwigPlugin\TwigPlugin' => array(
		// Where to store the compiled php templates.
		'cache' => __DIR__ . '/template_compilation_cache'
	)
));
```

Start using twig templates.

Functions
---------

[](#functions)

#### route

[](#route)

Reverse routing is easy.

```
Reverse routing:

{{"News.show"|route(32)}}
Prints forexample: /news/32

{{"News.index"|route()}}
Prints forexample: /news
```

```
Check if a route is active:

{% if "News.index"|route().isActive %}
Currently on homepage.
{% endif %}
```

Filters
-------

[](#filters)

#### asset

[](#asset)

Easily add assets, the assets will have the correct base path included.

```

Or from a variable

```

Tags
----

[](#tags)

#### cache

[](#cache)

Easily cache bits of your view, VERY good if you use a ORM that have lazy loading such as Doctrine!

```
{% cache "uniqueKey1" %}

	Hello I am cached forever!

{% endcache %}

{% cache "uniqueKey2" 3600 %}

	I am cached for 1 hour.

{% endcache %}
```

###  Health Score

20

—

LowBetter than 13% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/88b748fa2f0dcacab307a6305e98032de7adb93f955bbaf3c6fe029a7369ac84?d=identicon)[peec](/maintainers/peec)

---

Top Contributors

[![peec](https://avatars.githubusercontent.com/u/131546?v=4)](https://github.com/peec "peec (15 commits)")

### Embed Badge

![Health badge](/badges/pkj-minibase-plugin-twig/health.svg)

```
[![Health](https://phpackages.com/badges/pkj-minibase-plugin-twig/health.svg)](https://phpackages.com/packages/pkj-minibase-plugin-twig)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[area17/laravel-auto-head-tags

Laravel Auto Head Tags helps you build the list of head elements for your app

4616.0k](/packages/area17-laravel-auto-head-tags)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

281.8k](/packages/webkinder-sproutset)

PHPackages © 2026

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