PHPackages                             nguereza-tony/codeigniter-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. nguereza-tony/codeigniter-twig

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

nguereza-tony/codeigniter-twig
==============================

Integrate Twig to CodeIgniter 4

v1.0.0(1mo ago)03MITPHP ^7.4 || ^8.0

Since Jul 7Compare

[ Source](https://github.com/nguereza-tony/codeigniter-twig)[ Packagist](https://packagist.org/packages/nguereza-tony/codeigniter-twig)[ Docs](https://github.com/nongbit/codeigniter-twig#readme)[ RSS](/packages/nguereza-tony-codeigniter-twig/feed)WikiDiscussions Synced 1w ago

READMEChangelog (1)Dependencies (3)Versions (2)Used By (0)

Codeigniter Twig
================

[](#codeigniter-twig)

Integrate Twig to CodeIgniter 4.

Setup
-----

[](#setup)

Download package using composer.

```
composer require nguereza-tony/codeigniter-twig
```

Open `APPPATH/Controllers/BaseController.php`.

```
use Nongbit\Twig\Traits\Twig;

abstract class BaseController extends Controller
{
    use Twig;

    ...

    public function initController(...)
    {
        ...

        $this->initTwig();
    }
}
```

Usage
-----

[](#usage)

### Template

[](#template)

To display template, we can use `display()` provided by the trait.

```
$this->display('hello', ['title' => 'Acme'])
```

By default, Twig will look for template files inside `APPPATH/Views`. To add other locations use `addPath()`.

```
$this->twig->addPath(ROOTPATH . 'templates');
```

The default file extension is `html` but we can change it by creating a configuration file `App\Config\Twig.php`.

```
namespace Config;

use CodeIgniter\Config\BaseConfig;

class Twig extends BaseConfig
{
    public string $fileExtension = 'twig';
}
```

### Global

[](#global)

```
$this->twig->addGlobals('title', 'Acme');
$this->twig->addGlobals(['title' => 'Acme']);
```

Inside view:

```
{{ title }}
```

### Filter

[](#filter)

```
$this->twig->addFilters('rot13', 'rot13');
$this->twig->addFilters('rot13', function($string) {
    return str_rot13($string);
});
$this->twig->addFilters(['rot13']);
```

Inside view :

```
{{ 'Twig'|rot13 }}
```

### Function

[](#function)

Function behaves similarly to a filter.

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance90

Actively maintained with recent releases

Popularity3

Limited adoption so far

Community2

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Unknown

Total

1

Last Release

49d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/16177981?v=4)[Tony NGUEREZA](/maintainers/nguereza-tony)[@nguereza-tony](https://github.com/nguereza-tony)

---

Tags

twigcodeigniter

### Embed Badge

![Health badge](/badges/nguereza-tony-codeigniter-twig/health.svg)

```
[![Health](https://phpackages.com/badges/nguereza-tony-codeigniter-twig/health.svg)](https://phpackages.com/packages/nguereza-tony-codeigniter-twig)
```

###  Alternatives

[symfony/ux-twig-component

Twig components for Symfony

22020.2M443](/packages/symfony-ux-twig-component)[symfony/ux-live-component

Live components for Symfony

1657.5M155](/packages/symfony-ux-live-component)[shopware/storefront

Storefront for Shopware

674.7M288](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.8M683](/packages/shopware-core)[abydahana/aksara

Aksara is a modern, developer-friendly framework and CMS built on CodeIgniter 4, featuring rapid CRUD development, modular architecture, smart routing, flexible access control, API integration, and an AI assistant to make content management faster and smarter.

1141.2k](/packages/abydahana-aksara)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

16164.9k1](/packages/symfony-ux-toolkit)

PHPackages © 2026

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