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(3d ago)02MITPHP ^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 today

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

37

—

LowBetter than 81% of packages

Maintenance99

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

3d 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

22018.6M364](/packages/symfony-ux-twig-component)[symfony/ux-live-component

Live components for Symfony

1647.0M131](/packages/symfony-ux-live-component)[shopware/storefront

Storefront for Shopware

674.6M239](/packages/shopware-storefront)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

585.6M582](/packages/shopware-core)[symfony/ux-toolkit

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

16126.1k1](/packages/symfony-ux-toolkit)[abydahana/aksara

Aksara is a CodeIgniter based CRUD Toolkit you can use to build complex applications become shorter, secure and more reliable just in a few lines of code. Serving both CMS or Framework, produce both HEADLESS (RESTful API) or TRADITIONAL (Browser Based), just by writing single controller. Yet it's reusable, scalable and ready to use!

1111.2k](/packages/abydahana-aksara)

PHPackages © 2026

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