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

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

litphp/view-twig
================

Twig integration for lit

v0.9.0(6y ago)013ISCPHP

Since May 12Pushed 6y ago1 watchersCompare

[ Source](https://github.com/litphp/view-twig)[ Packagist](https://packagist.org/packages/litphp/view-twig)[ RSS](/packages/litphp-view-twig/feed)WikiDiscussions master Synced 3d ago

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

TwigView for lit
================

[](#twigview-for-lit)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/12e32de57813542ddc363e5436da666ea0f33cb029a99c02233c2497ef674e15/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c69745048502f766965772d747769672f6261646765732f7175616c6974792d73636f72652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/LitPHP/view-twig/?branch=master)[![Code Coverage](https://camo.githubusercontent.com/cac90ee845f0104abca43e6030fad45b2c62cc36fe69431600636b7fe2a73058/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c69745048502f766965772d747769672f6261646765732f636f7665726167652e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/LitPHP/view-twig/?branch=master)[![Build Status](https://camo.githubusercontent.com/fbe2aeb1110051e56a591bce46202e965fdadb8716291e8d7efbbab4b5cef111/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f4c69745048502f766965772d747769672f6261646765732f6275696c642e706e673f623d6d6173746572)](https://scrutinizer-ci.com/g/LitPHP/view-twig/build-status/master)

> Twig integration for lit

### Usage

[](#usage)

In a standard [litphp/project](https://github.com/litphp/project):

- add dependency &amp; install

```
composer require litphp/view-twig
```

- append configuration

Create a template dir in your project root, says `template`. Write your first template file `templates/index.twig`

```
Hello {{name}}!
```

Merge `TwigView::configuration` into your `configuration.php`.

```
$configuration += \Lit\View\Twig\TwigView::configuration(C::instance(\Twig\Loader\FilesystemLoader::class, [
    __DIR__ . '/templates',
]));
```

- integration in action class

In `src/BaseAction.php`, use the trait `TwigViewBuilderTrait`

```
abstract class BaseAction extends BoltAbstractAction
{
    use \Lit\View\Twig\TwigViewBuilderTrait;
```

Change your `src/HomeAction.php` to render page use twig

```
class HomeAction extends BaseAction
{
    protected function main(): ResponseInterface
    {
        return $this->twig('index.twig')->render(['name' => 'twig']);
    }
```

That's all! Run your app by `php -S 127.0.0.1:3080 public/index.php`, and open . You should see greetings from twig template "Hello twig!"

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity5

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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.

###  Release Activity

Cadence

Every ~48 days

Total

2

Last Release

2511d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/775be499f40ae974a25327900e28fa6eba931b1c7a4332097d027127ba582ba2?d=identicon)[mcfog](/maintainers/mcfog)

---

Top Contributors

[![mcfog](https://avatars.githubusercontent.com/u/524075?v=4)](https://github.com/mcfog "mcfog (11 commits)")

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[twig/intl-extra

A Twig extension for Intl

36663.2M221](/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.0M133](/packages/twig-string-extra)[twig/cssinliner-extra

A Twig extension to allow inlining CSS

23018.5M55](/packages/twig-cssinliner-extra)[symfony/ux-twig-component

Twig components for Symfony

21814.8M162](/packages/symfony-ux-twig-component)[twig/markdown-extra

A Twig extension for Markdown

12114.3M83](/packages/twig-markdown-extra)

PHPackages © 2026

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