PHPackages                             goetas/twital - 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. goetas/twital

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

goetas/twital
=============

PHP templating engine that combines Twig and PHPTal power points

v1.5.1(1y ago)12813.1k14[5 issues](https://github.com/goetas/twital/issues)[1 PRs](https://github.com/goetas/twital/pulls)1MITPHPPHP ^7.1|^8.0CI failing

Since Apr 2Pushed 1y ago10 watchersCompare

[ Source](https://github.com/goetas/twital)[ Packagist](https://packagist.org/packages/goetas/twital)[ Docs](https://github.com/goetas/twital)[ RSS](/packages/goetas-twital/feed)WikiDiscussions master Synced 3w ago

READMEChangelog (10)Dependencies (7)Versions (24)Used By (1)

[![Build Status](https://camo.githubusercontent.com/9696052c91e2f8a1c27dc6dcd9d8f7ae2b936bf93c93100f490dfbdf5ac64de9/68747470733a2f2f7472617669732d63692e6f72672f676f657461732f74776974616c2e706e673f6272616e63683d646576)](https://travis-ci.org/goetas/twital)[![Scrutinizer Quality Score](https://camo.githubusercontent.com/c6e03b5d35b3f910d4fc68ceda9318902f6927943e57f5c4ac6ab00866f73aff/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676f657461732f74776974616c2f6261646765732f7175616c6974792d73636f72652e706e673f733d36313761633035386663336334383634323737353266643366623166333933316263613937316564)](https://scrutinizer-ci.com/g/goetas/twital/)[![Code Coverage](https://camo.githubusercontent.com/a28a1a6201f20430e8f11317c8c3650a47fb0552362162402e6cc4486e1eab05/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f676f657461732f74776974616c2f6261646765732f636f7665726167652e706e673f733d64653864373134626534613937623462313162623434613266663636303164626461383636393663)](https://scrutinizer-ci.com/g/goetas/twital/)[![GitHub license](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](https://raw.githubusercontent.com/goetas/twital/master/LICENSE)[![Packagist](https://camo.githubusercontent.com/a30d53421b0e05742890e68327f9f8c4370011149edaa3e2b5055c6e7bddfe27/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f676f657461732f74776974616c2e737667)](https://packagist.org/packages/goetas/twital)

What is Twital?
===============

[](#what-is-twital)

Twital is a template engine built on top of [Twig](http://twig.sensiolabs.org/)(a template engine for PHP and default template engine on Symfony) that adds some shortcuts and makes Twig's syntax more suitable for HTML based (XML, HTML5, XHTML, SGML) templates. Twital takes inspiration from [PHPTal](http://phptal.org/), [TAL](http://en.wikipedia.org/wiki/Template_Attribute_Language)and [AngularJS](http://angularjs.org/) or [Vue.js](https://vuejs.org/) (just for some aspects), mixing their language syntaxes with the powerful Twig templating engine system.

Twital is fully compatible with Twig, all Twig templates can be rendered using Twital.

To better understand the Twital's benefits, consider the following **Twital** template, which simply shows a list of users from an array:

```

        {{ user.name }}

```

To do the same thing using Twig, you need:

```
{% if users %}

        {% for user in users %}

                {{ user.name }}

        {% endfor %}

{% endif %}
```

As you can see, the Twital template is **more readable**, **less verbose** and and **you don't have to worry about opening and closing block instructions**(they are inherited from the HTML structure).

One of the main advantages of Twital is the *implicit* presence of control statements, which makes templates more readable and less verbose. Furthermore, it has all Twig functionalities, such as template inheritance, translations, looping, filtering, escaping, etc.

If some Twig functionality is not directly available for Twital, you can **freely mix Twig and Twital** syntaxes.

In the example below, we have mixed Twital and Twig syntaxes to use Twig custom tags:

```

    {% custom_tag %}
        {{ someUnsafeVariable }}
    {% endcustom_tag %}

```

When needed, you can extend from a Twig template:

```

        Hello {{name}}!

```

You can also extend from Twig a Twital template:

```
{% extends "layout.twital" %}

{% block content %}
    Hello {{name}}!
{% endblock %}

```

A presentation of Twital features and advantages is available on [this presentation](https://goetas.bitbucket.io/twital-02-08-2016-berlin-ug/#/).

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

[](#installation)

The recommended ways install Twital is via [Composer](https://getcomposer.org/).

```
composer require goetas/twital
```

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

[](#documentation)

Go here  to read a more detailed documentation about Twital.

Getting started
---------------

[](#getting-started)

First, you have to create a file that contains your template (named for example `demo.twital.html`):

```

    Hello {{ name }}

```

Afterwards, you have to create a PHP script that instantiate the required objects:

```
require_once '/path/to/composer/vendor/autoload.php';
use Goetas\Twital\TwitalLoader;

$fileLoader = new Twig_Loader_Filesystem('/path/to/templates');
$twitalLoader = new TwitalLoader($fileLoader);

$twig = new Twig_Environment($twitalLoader);
echo $twig->render('demo.twital.html', array('name' => 'John'));
```

That's it!

Symfony Users
-------------

[](#symfony-users)

If you are a [Symfony](http://symfony.com/) user, you can add Twital to your project using the [TwitalBundle](https://github.com/goetas/twital-bundle).

The bundle integrates all most common functionalities as Assetic, Forms, Translations, Routing, etc.

Twig Users
----------

[](#twig-users)

Starting from version Twital 1.0.0, both twig 1.x and 2.x versions are supported.

Note
----

[](#note)

The code in this project is provided under the [MIT](https://opensource.org/licenses/MIT) license. For professional support contact or visit

###  Health Score

49

—

FairBetter than 94% of packages

Maintenance44

Moderate activity, may be stable

Popularity38

Limited adoption so far

Community24

Small or concentrated contributor base

Maturity78

Established project with proven stability

 Bus Factor1

Top contributor holds 81.2% 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 ~192 days

Recently: every ~576 days

Total

22

Last Release

434d ago

Major Versions

0.1.9 → v1.0.02017-01-06

PHP version history (4 changes)0.1.0-betaPHP &gt;=5.3.3

v1.2.1PHP ^5.3.3||^7.0

v1.3.0PHP ^5.5|^7.0

v1.4.0PHP ^7.1|^8.0

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/776743?v=4)[Asmir Mustafic](/maintainers/goetas)[@goetas](https://github.com/goetas)

---

Top Contributors

[![goetas](https://avatars.githubusercontent.com/u/776743?v=4)](https://github.com/goetas "goetas (181 commits)")[![hason](https://avatars.githubusercontent.com/u/288535?v=4)](https://github.com/hason "hason (28 commits)")[![soukicz](https://avatars.githubusercontent.com/u/1814750?v=4)](https://github.com/soukicz "soukicz (7 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (2 commits)")[![tzi](https://avatars.githubusercontent.com/u/415891?v=4)](https://github.com/tzi "tzi (1 commits)")[![Wirone](https://avatars.githubusercontent.com/u/600668?v=4)](https://github.com/Wirone "Wirone (1 commits)")[![lyrixx](https://avatars.githubusercontent.com/u/408368?v=4)](https://github.com/lyrixx "lyrixx (1 commits)")[![pborreli](https://avatars.githubusercontent.com/u/77759?v=4)](https://github.com/pborreli "pborreli (1 commits)")[![petrhanak](https://avatars.githubusercontent.com/u/7580926?v=4)](https://github.com/petrhanak "petrhanak (1 commits)")

---

Tags

angularjshtml5phpphptaltemplate-enginetwigtwig-syntaxtwig-templatesxmlphpxmltwigtemplating

###  Code Quality

TestsPHPUnit

Code StylePHP CS Fixer

### Embed Badge

![Health badge](/badges/goetas-twital/health.svg)

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

###  Alternatives

[matomo/matomo

Matomo is the leading Free/Libre open analytics platform

21.7k38.9k](/packages/matomo-matomo)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M386](/packages/easycorp-easyadmin-bundle)[drupal/core

Drupal is an open source content management platform powering millions of websites and applications.

21866.0M1.7k](/packages/drupal-core)[symfony/ux-twig-component

Twig components for Symfony

22018.6M356](/packages/symfony-ux-twig-component)[drupal/core-recommended

Locked core dependencies; require this project INSTEAD OF drupal/core.

6942.5M421](/packages/drupal-core-recommended)[timber/timber

Create WordPress themes with beautiful OOP code and the Twig Template Engine

5.7k3.7M132](/packages/timber-timber)

PHPackages © 2026

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