PHPackages                             pieceofcake2/twig-view - 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. pieceofcake2/twig-view

ActiveCakephp-plugin[Templating &amp; Views](/categories/templating)

pieceofcake2/twig-view
======================

Twig for CakePHP 2.x

v2.0.2(7mo ago)00MITPHPPHP &gt;=8.1CI passing

Since Oct 10Pushed 6mo agoCompare

[ Source](https://github.com/pieceofcake2/twig-view)[ Packagist](https://packagist.org/packages/pieceofcake2/twig-view)[ RSS](/packages/pieceofcake2-twig-view/feed)WikiDiscussions 2.x Synced 1mo ago

READMEChangelogDependencies (8)Versions (2)Used By (0)

TwigView plugin for CakePHP 2
=============================

[](#twigview-plugin-for-cakephp-2)

[![GitHub License](https://camo.githubusercontent.com/848b4a96f14ea00a6790ba1ebd3983700f7e41316a407d8faac01c29e3388002/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f70696563656f6663616b65322f747769672d766965773f6c6162656c3d4c6963656e7365)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/8149b9c0a1190d17803a7704ce0b2509a7b9f095e445f23bfbcfe371a6c162ae/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f70696563656f6663616b65322f747769672d766965773f6c6162656c3d5061636b6167697374)](https://packagist.org/packages/pieceofcake2/twig-view)[![PHP](https://camo.githubusercontent.com/241700fcdb4141f696b41b4c4809c6c61180ea007fbf9a1002d66ef51cb06b56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f747769672d766965772f7068703f6c6f676f3d706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d504850266c6162656c436f6c6f723d25323337373762623426636f6c6f723d253233666666666666)](https://camo.githubusercontent.com/241700fcdb4141f696b41b4c4809c6c61180ea007fbf9a1002d66ef51cb06b56/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f747769672d766965772f7068703f6c6f676f3d706870266c6f676f436f6c6f723d253233464646464646266c6162656c3d504850266c6162656c436f6c6f723d25323337373762623426636f6c6f723d253233666666666666)[![CakePHP](https://camo.githubusercontent.com/3e07959c8eefb00e52c1c712e2628bc7f9a1c1e563fbc0f2afa0cc08a0b8ad20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f747769672d766965772f70696563656f6663616b65322f63616b657068703f6c6f676f3d63616b65706870266c6f676f436f6c6f723d253233666666666666266c6162656c3d43616b65504850266c6162656c436f6c6f723d25323344333343343326636f6c6f723d253233666666666666)](https://camo.githubusercontent.com/3e07959c8eefb00e52c1c712e2628bc7f9a1c1e563fbc0f2afa0cc08a0b8ad20/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f747769672d766965772f70696563656f6663616b65322f63616b657068703f6c6f676f3d63616b65706870266c6f676f436f6c6f723d253233666666666666266c6162656c3d43616b65504850266c6162656c436f6c6f723d25323344333343343326636f6c6f723d253233666666666666)[![Twig](https://camo.githubusercontent.com/432d16d741cd8c31bf35f5b5bf1cc1fb1551f06af562ae867ae8de0e2ae447b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f747769672d766965772f74776967253246747769673f6c6f676f3d64617461253341696d616765253246737667253242786d6c25334262617365363425324350484e325a79423361575230614430694d5449694947686c6157646f644430694d54496949485a705a58644362336739496a41674d4341784d6941784d6949675a6d6c7362443069626d39755a53496765473173626e4d39496d6830644841364c79393364336375647a4d7562334a6e4c7a49774d44417663335a6e496a34385a79426a62476c774c58426864476739496e56796243676a59327870634442664d5638784d436b69506a78775958526f49475139496b307a4c6a49334d6a6378494441754e7a63784e446730517a51754e7a55794d6a6b674d4334314d7a4d334f4341324c6a41354d445535494449754e4449784d4463674e6934304e7a59344d5341794c6a6b324d6a6735517a63754d5467314e546b674d7934354e7a59304e7941334c6a59794d54517a494455754d5455314e6a51674e7934334e4441304f4341324c6a4d344e6a6379517a63754e7a49344d4459674e6934304d4451774f5341334c6a63784e545530494459754e4449784f5449674e7934334d444d7a4e7941324c6a517a4f545131517a67754d7a63324e5449674e5334314e546b784e4341354c6a51794d7a4979494451754f4463774e7a63674d5441754d6a417a4e4341314c6a45344f545131517a45784c6a41784e6a49674e5334314d6a45334f4341784d5334794d5467674e6934344d5445344d7941784d5334784e544d32494459754f4455774e546c444d5445754d446b334e7941324c6a67334f545132494445774c6a67784e7a51674e6934774d6a49354d5341784d4334794e6a6334494455754f5463304e6a46444f5334334f444d334d5341314c6a6b7a4d6a593049446b754d7a63794f5445674e6934314e6a45304f4341354c6a4d774d444131494459754e6a63794f4456444f5334774d4441774e5341334c6a45794f445134494467754f5449324f5445674e7934324d6a41774d7941344c6a6b324d6a4532494467754f444d794d444e444f4334354f4459344d6941354c6a59304d4455674f5334774e446b304d5341784d4334304e44633049446b754d5451354e6a59674d5445754d6a564d4e6934324f5441324e7941784d5334794e5446574d5445754d6a56494d7934344f5451334f454d7a4c6a6b7a4d7a6334494445774c6a59334d546b674d7934354d5445354f5341784d4334774f54457849444d754f4449354d7a55674f5334314d5463314f454d7a4c6a63314f444135494467754e5455344e446b674d7934304d7a6b334d5341334c6a597a4e444d33494449754f5441324e446b674e6934344d7a4d354f454d794c6a417a4f546733494455754e6a67314d7a59674d4334334e7a41304f4459674e5334304d7a63304e6941774c6a677a4f5445784d5341314c6a49794e545535517a41754f446b304e54457a494455754d4455344e4445674d5334334e6a51344e7941314c6a45794f544531494449754e5451784d6a59674e53347a4d7a55354e454d7a4c6a45324e445535494455754e5441784f546b674e4334784d5467334f4341314c6a677a4e7a4578494455754d6a41784e4449674e6934334d7a49304d6b4d304c6a67344e7a677849444d754d4441314e7a51674e4334784e5459324d6941784c6a63344f546b3549444d754d7a67314d4445674d5334324d544d794f454d794c6a59314d6a5533494445754e4451324d5341784c6a67784d7a6378494449754d546b344d6a51674d5334334d5455774f5341794c6a41304f44677a517a45754e6a45794d7a51674d5334344f5455304e5341794c6a4d784f446378494441754f5449304e44673049444d754d6a63794e7a45674d4334334e7a45304f4452614969426d6157787350534a3361476c305a534976506a77765a7a34384c334e325a7a34253344266c6162656c3d54776967266c6162656c436f6c6f723d25323337666130323026636f6c6f723d253233666666666666)](https://camo.githubusercontent.com/432d16d741cd8c31bf35f5b5bf1cc1fb1551f06af562ae867ae8de0e2ae447b8/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f70696563656f6663616b65322f747769672d766965772f74776967253246747769673f6c6f676f3d64617461253341696d616765253246737667253242786d6c25334262617365363425324350484e325a79423361575230614430694d5449694947686c6157646f644430694d54496949485a705a58644362336739496a41674d4341784d6941784d6949675a6d6c7362443069626d39755a53496765473173626e4d39496d6830644841364c79393364336375647a4d7562334a6e4c7a49774d44417663335a6e496a34385a79426a62476c774c58426864476739496e56796243676a59327870634442664d5638784d436b69506a78775958526f49475139496b307a4c6a49334d6a6378494441754e7a63784e446730517a51754e7a55794d6a6b674d4334314d7a4d334f4341324c6a41354d445535494449754e4449784d4463674e6934304e7a59344d5341794c6a6b324d6a6735517a63754d5467314e546b674d7934354e7a59304e7941334c6a59794d54517a494455754d5455314e6a51674e7934334e4441304f4341324c6a4d344e6a6379517a63754e7a49344d4459674e6934304d4451774f5341334c6a63784e545530494459754e4449784f5449674e7934334d444d7a4e7941324c6a517a4f545131517a67754d7a63324e5449674e5334314e546b784e4341354c6a51794d7a4979494451754f4463774e7a63674d5441754d6a417a4e4341314c6a45344f545131517a45784c6a41784e6a49674e5334314d6a45334f4341784d5334794d5467674e6934344d5445344d7941784d5334784e544d32494459754f4455774e546c444d5445754d446b334e7941324c6a67334f545132494445774c6a67784e7a51674e6934774d6a49354d5341784d4334794e6a6334494455754f5463304e6a46444f5334334f444d334d5341314c6a6b7a4d6a593049446b754d7a63794f5445674e6934314e6a45304f4341354c6a4d774d444131494459754e6a63794f4456444f5334774d4441774e5341334c6a45794f445134494467754f5449324f5445674e7934324d6a41774d7941344c6a6b324d6a4532494467754f444d794d444e444f4334354f4459344d6941354c6a59304d4455674f5334774e446b304d5341784d4334304e44633049446b754d5451354e6a59674d5445754d6a564d4e6934324f5441324e7941784d5334794e5446574d5445754d6a56494d7934344f5451334f454d7a4c6a6b7a4d7a6334494445774c6a59334d546b674d7934354d5445354f5341784d4334774f54457849444d754f4449354d7a55674f5334314d5463314f454d7a4c6a63314f444135494467754e5455344e446b674d7934304d7a6b334d5341334c6a597a4e444d33494449754f5441324e446b674e6934344d7a4d354f454d794c6a417a4f546733494455754e6a67314d7a59674d4334334e7a41304f4459674e5334304d7a63304e6941774c6a677a4f5445784d5341314c6a49794e545535517a41754f446b304e54457a494455754d4455344e4445674d5334334e6a51344e7941314c6a45794f544531494449754e5451784d6a59674e53347a4d7a55354e454d7a4c6a45324e445535494455754e5441784f546b674e4334784d5467334f4341314c6a677a4e7a4578494455754d6a41784e4449674e6934334d7a49304d6b4d304c6a67344e7a677849444d754d4441314e7a51674e4334784e5459324d6941784c6a63344f546b3549444d754d7a67314d4445674d5334324d544d794f454d794c6a59314d6a5533494445754e4451324d5341784c6a67784d7a6378494449754d546b344d6a51674d5334334d5455774f5341794c6a41304f44677a517a45754e6a45794d7a51674d5334344f5455304e5341794c6a4d784f446378494441754f5449304e44673049444d754d6a63794e7a45674d4334334e7a45304f4452614969426d6157787350534a3361476c305a534976506a77765a7a34384c334e325a7a34253344266c6162656c3d54776967266c6162656c436f6c6f723d25323337666130323026636f6c6f723d253233666666666666)[![CI](https://camo.githubusercontent.com/d476dedcb1c696972eeb8a823874a479a4e87ab3241679a048f2805551a3deeb/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f70696563656f6663616b65322f747769672d766965772f43492e796d6c3f6c6162656c3d4349)](https://github.com/pieceofcake2/twig-view/actions/workflows/CI.yml)[![Codecov](https://camo.githubusercontent.com/61edd361bd1c1b9b7c3096f8eccf4a43caa1c29eca5885e9f9e5bef1a542545c/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f67682f70696563656f6663616b65322f747769672d766965773f6c6162656c3d436f766572616765)](https://codecov.io/gh/pieceofcake2/twig-view)

Modern Twig 3.x support for CakePHP 2.x with PSR-4 namespaces and PHP 8.1+.

This plugin integrates the [Twig Templating Language](https://twig.symfony.com/) with [CakePHP 2](https://book.cakephp.org/2.0/en/), providing access to helpers, elements, and themes.

Note

For CakePHP 5.x, use the official [cakephp/twig-view](https://github.com/cakephp/twig-view) package instead.

Requirements
------------

[](#requirements)

- PHP 8.1+
- CakePHP 2.12+
- Twig 3.x

Installation
------------

[](#installation)

Install via Composer:

```
composer require pieceofcake2/twig-view
```

Load the plugin in your `app/Config/bootstrap.php`:

```
CakePlugin::load('TwigView');
// or
CakePlugin::loadAll();
```

Quick Start
-----------

[](#quick-start)

Set the view class in your `app/Controller/AppController.php`:

```
class AppController extends Controller
{
    public $viewClass = 'TwigView.Twig';
}
```

Create templates with `.twig` extension:

```
{# app/View/Posts/index.twig #}
{% for post in posts %}
    {{ post.Post.title }}
    {{ post.Post.body }}
{% endfor %}
```

Documentation
-------------

[](#documentation)

- **[Function &amp; Filter Reference](docs/reference.md)** - Complete list of available Twig functions and filters
- **[Using Helpers](docs/helpers.md)** - How to use CakePHP helpers in Twig templates
- **[Configuration](docs/configuration.md)** - Advanced configuration options
- **[Extensions](docs/extensions.md)** - Popular Twig extensions
- **[Examples](examples/)** - Example layouts and templates

Features
--------

[](#features)

- **CakePHP Integration**: Full access to helpers, elements, and themes
- **Custom Extensions**: Extend Twig with custom filters and functions
- **Theme Support**: Compatible with CakePHP's themed views
- **Plugin Support**: Works with both `View/` and `templates/` directories
- **Pre-compilation**: Compile templates for production performance
- **PSR-4 Namespaces**: Modern PHP architecture

Fork History
------------

[](#fork-history)

This project is based on the following repositories:

1. [m3nt0r-legacy/cakephp-twig-view](https://github.com/m3nt0r-legacy/cakephp-twig-view) - Original implementation by Kjell Bublitz
2. [predominant/TwigView](https://github.com/predominant/TwigView) - Fork by Graham Weldon (archived in 2019) - **Direct fork source**
3. [cakephp/legacy-twig-view](https://github.com/cakephp/legacy-twig-view) - CakePHP community version (formerly WyriHaximus/TwigView, deprecated)
4. **pieceofcake2/twig-view** (this repository) - Modernized fork with Twig 3.x and PHP 8.1+ support

The original repositories supported Twig 1.x with CakePHP 2.x but are no longer maintained. This fork updates the codebase to work with modern PHP and Twig versions while maintaining CakePHP 2.x compatibility.

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance65

Regular maintenance activity

Popularity0

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity44

Maturing project, gaining track record

 Bus Factor2

2 contributors hold 50%+ of commits

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

Total

2

Last Release

208d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/35c2da973a64a21e8d23c221c1d284e4f1a04a74123318a978147e42a29eda23?d=identicon)[ttsuru](/maintainers/ttsuru)

---

Top Contributors

[![m3nt0r](https://avatars.githubusercontent.com/u/23321?v=4)](https://github.com/m3nt0r "m3nt0r (43 commits)")[![predominant](https://avatars.githubusercontent.com/u/24568?v=4)](https://github.com/predominant "predominant (39 commits)")[![ttsuru](https://avatars.githubusercontent.com/u/578548?v=4)](https://github.com/ttsuru "ttsuru (17 commits)")[![SamFleming](https://avatars.githubusercontent.com/u/573318?v=4)](https://github.com/SamFleming "SamFleming (2 commits)")[![joseayram](https://avatars.githubusercontent.com/u/1056297?v=4)](https://github.com/joseayram "joseayram (1 commits)")[![jorgonor](https://avatars.githubusercontent.com/u/523390?v=4)](https://github.com/jorgonor "jorgonor (1 commits)")[![prihoda](https://avatars.githubusercontent.com/u/2894124?v=4)](https://github.com/prihoda "prihoda (1 commits)")[![rewish](https://avatars.githubusercontent.com/u/55593?v=4)](https://github.com/rewish "rewish (1 commits)")[![shama](https://avatars.githubusercontent.com/u/99604?v=4)](https://github.com/shama "shama (1 commits)")[![lorenzo](https://avatars.githubusercontent.com/u/37621?v=4)](https://github.com/lorenzo "lorenzo (1 commits)")[![iknowthis](https://avatars.githubusercontent.com/u/109137?v=4)](https://github.com/iknowthis "iknowthis (1 commits)")

---

Tags

twigcakephpviewcakephp2

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/pieceofcake2-twig-view/health.svg)

```
[![Health](https://phpackages.com/badges/pieceofcake2-twig-view/health.svg)](https://phpackages.com/packages/pieceofcake2-twig-view)
```

###  Alternatives

[twig/extra-bundle

A Symfony bundle for extra Twig extensions

91292.0M314](/packages/twig-extra-bundle)[wyrihaximus/twig-view

Twig powered View for CakePHP

804.7M1](/packages/wyrihaximus-twig-view)[twig/intl-extra

A Twig extension for Intl

36663.2M220](/packages/twig-intl-extra)[rcrowe/twigbridge

Adds the power of Twig to Laravel

9105.9M50](/packages/rcrowe-twigbridge)[twig/string-extra

A Twig extension for Symfony String

21946.0M132](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

23018.5M53](/packages/twig-cssinliner-extra)

PHPackages © 2026

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