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

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

koolreport/twig
===============

Allow KoolReport to use twig template engine to render view

1.0.0(7y ago)01.7kMITPHP

Since Jun 1Pushed 5y ago1 watchersCompare

[ Source](https://github.com/koolreport/twig)[ Packagist](https://packagist.org/packages/koolreport/twig)[ Docs](https://www.koolreport.com)[ RSS](/packages/koolreport-twig/feed)WikiDiscussions master Synced 5d ago

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

Twig
====

[](#twig)

Overview
--------

[](#overview)

Starting from version 4.0.0, KoolReport supports other template engines rather than just its own template view file. `Twig` is one of the popular template engines that KoolReport supports.

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

[](#installation)

#### By downloading .zip file

[](#by-downloading-zip-file)

1. [Download](https://www.koolreport.com/packages/twig)
2. Unzip the zip file
3. Copy the folder `twig` into `koolreport` folder so that look like below

```
koolreport
├── core
├── twig
```

#### By composer

[](#by-composer)

```
composer require koolreport/twig

```

Get started
-----------

[](#get-started)

**Step 1:** Add the twig service to your report

```
class Report extends \koolreport\KoolReport
{
    use \koolreport\clients\Bootstrap;

    use \koolreport\twig\Engine;
    protected function twigInit()
    {
        $loader = new \Twig\Loader\FilesystemLoader(dirname(__FILE__).'/views');
        $twig = new \Twig\Environment($loader);
        return $twig;
    }
    ...
}

```

**Step 2:** Create the view `report.html` inside `views` folder like below:

```

    Welcome to Twig

    Welcome to Twig
    {{
        widget('koolreport.widgets.koolphp.Table',{
            dataSource:report.dataStore("data"),
        })
    }}

```

**Step 3:** You can run your report with following line of code

```
$report = new Report;
$report->run()->render("report.html");

```

**Congrat**, Now you can use Twig to design your report.

Some notes:
-----------

[](#some-notes)

1. In your template, you refer to report object with parameter `report`
2. When use function `widget()` to generate koolreport's widget, you should change the backslash `\` in the class name to dot `"."`, for example, you change: `\koolreport\widgets\koolphp\Table` to `koolreport.widgets.koolphp.Table`
3. You can reference to any datastore with `report.dataStore("name_of_datastore")`

Limitation
----------

[](#limitation)

There are some limitation due to the fact that `Twig` does not allow PHP to run within. This limits some of capability of KoolReport's widget such as defining anonymous function. For example, there is no way to define custom function to format value in Table widget like this.

```
Table::create(array(
    ...
    "columns"=>array(
        "id"=>array(
            "formatValue"=>function($value)
            {
                return "View";
            }
        )
    )
))

```

Simply it is not able to transform above php code to json definition in twig.

Resources
=========

[](#resources)

1. [Full documentation](https://www.koolreport.com/docs/twig/overview/)
2. [Examples &amp; Demonstration](https://www.koolreport.com/examples)

Support
=======

[](#support)

Please use [our forum](https://www.koolreport.com/forum/topics) if you need support, by this way other people can benefit as well. If the support request need privacy, you may send email to us at .

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% 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

Unknown

Total

1

Last Release

2590d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/9a27c60d0b76ca63f2216334e1e7668bff2b75ef9ffcc601855d738f29e17dab?d=identicon)[koolreport](/maintainers/koolreport)

---

Top Contributors

[![tuananhnghiem](https://avatars.githubusercontent.com/u/7497712?v=4)](https://github.com/tuananhnghiem "tuananhnghiem (10 commits)")[![koolreport](https://avatars.githubusercontent.com/u/47791618?v=4)](https://github.com/koolreport "koolreport (1 commits)")

---

Tags

mysql-reporting-toolsphp-reporting-toolsreporting-toolstemplate-enginetwigtwig-enginetwig-templatesphptwigtemplate engineData ReportReporting Tools

### Embed Badge

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

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

###  Alternatives

[symfony/ux-twig-component

Twig components for Symfony

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

Live components for Symfony

1647.0M128](/packages/symfony-ux-live-component)[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)[mati365/ckeditor5-symfony

CKEditor 5 integration for Symfony

262.6k](/packages/mati365-ckeditor5-symfony)

PHPackages © 2026

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