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

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

pug/twig
========

Compile Pug templates into Twig templates

1.3.0(2mo ago)116232[2 issues](https://github.com/pug-php/twig/issues)MITPHPPHP &gt;=5.5CI passing

Since Nov 30Pushed 2mo ago2 watchersCompare

[ Source](https://github.com/pug-php/twig)[ Packagist](https://packagist.org/packages/pug/twig)[ GitHub Sponsors](https://github.com/kylekatarnls)[ Fund](https://opencollective.com/pug-php)[ RSS](/packages/pug-twig/feed)WikiDiscussions master Synced 2d ago

READMEChangelog (8)Dependencies (12)Versions (11)Used By (0)

PugToTwig
=========

[](#pugtotwig)

[![Latest Stable Version](https://camo.githubusercontent.com/2a000802a8a36ec0063be5557329a85164421819abe955ab575e9c01ce5986f1/68747470733a2f2f706f7365722e707567782e6f72672f7075672f747769672f762f737461626c652e706e67)](https://packagist.org/packages/pug/twig)[![Build Status](https://camo.githubusercontent.com/d487945efbc6c4ed13d9a9ea0c8be71abc0e10c2c460b77880dabe67464553a6/68747470733a2f2f7472617669732d63692e6f72672f7075672d7068702f747769672e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/pug-php/twig)[![Test Coverage](https://camo.githubusercontent.com/5f18340eca9a2ef516301a19f062cbe5f287827cbfbe21324d633bdd24b57492/68747470733a2f2f636f6465636c696d6174652e636f6d2f6769746875622f7075672d7068702f747769672f6261646765732f636f7665726167652e737667)](https://codeclimate.com/github/pug-php/twig/coverage)[![StyleCI](https://camo.githubusercontent.com/3f798bbd4eac8bc57becb18e132a83947ec6848e74a9283a07048208f51e1b57/68747470733a2f2f7374796c6563692e696f2f7265706f732f3131323439303734302f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/112490740)

This package can convert basic pug codes into **Twig** code. Caution, this package should not be used to handle **Pug** templates in Symfony, the right way to do it is to use [pug-symfony](https://github.com/pug-php/pug-symfony)and to either polyfill Twig expressions only or delegate expression handle to the **Twig** code parser.

This package can help you moving from **Pug** to **Twig** by generating equivalent code or can be used to create a **Pug** input interface to insert **Twig** templates in an existing application. These are the only kind of business you should handle with this package.

For a full-featured **Pug** template engine in **Symfony**[pug-symfony](https://github.com/pug-php/pug-symfony)is what you need. If you miss a feature, ask in the issues, there probably already exists a way to do the same, else we'll try to add it.

Instalation
-----------

[](#instalation)

First install composer if you have not:

Then run the following command:

```
composer require pug/twig
```

Or if you installed composer locally:

```
php composer.phar require pug/twig
```

Extension for Phug/Pug-php to output Twig (PHP pug to twig converter)

**my-pug-input.pug**:

```
ul#users
  - for user in users
    li.user
      // comment
      = user.name
      | Email: #{user.email}
      a(href=user.url) Home page
```

**index.php**:

```
include 'vendor/autoload.php';

echo PugToTwig::convert(file_get_contents('my-pug-input.pug'));
```

Will output:

```

  {% for user in users %}

      {#  comment #}
      {{ user.name | e }}
      Email: {{ user.email | e }}
      Home page

  {% endfor %}

```

(indentation not guaranteed).

Some features such as mixins could output PHP that you would need to evaluate:

```
$html = eval('?>' . PugToTwig::convert($pugCode));

```

Warning: you should be sure you don't let user input appears between ``. It should not happen easily because expressions and codes are turned into **Twig** code that the PHP `eval` will just ignore, but be careful.

### Not supported features:

[](#not-supported-features)

- **Mixins with dynamic names**
- **Mixins arguments**: de facto, argument display will become Twig interpolation and Twig can't handle pug mixins, so mixins are evaluated before Twig will evaluate code/expressions.

###  Health Score

48

—

FairBetter than 94% of packages

Maintenance84

Actively maintained with recent releases

Popularity21

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity64

Established project with proven stability

 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 ~432 days

Recently: every ~542 days

Total

8

Last Release

60d ago

Major Versions

0.1.0 → 1.0.02018-08-09

### Community

Maintainers

![](https://www.gravatar.com/avatar/df90c422f521bf26355c3e185a59fe7afb35531af56244dfaec03ee1d0ca6f24?d=identicon)[kylekatarn](/maintainers/kylekatarn)

---

Top Contributors

[![kylekatarnls](https://avatars.githubusercontent.com/u/5966783?v=4)](https://github.com/kylekatarnls "kylekatarnls (40 commits)")

---

Tags

phpsymfonytwightmljadepugphug

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[phug/phug

Pug (ex-Jade) facade engine for PHP, HTML template engine structured by indentation

67292.2k13](/packages/phug-phug)[talesoft/tale-pug

A clean, lightweight and easy-to-use templating engine for PHP based on Pug, formerly Jade

319.4k3](/packages/talesoft-tale-pug)[talesoft/tale-jade

A clean, lightweight and easy-to-use templating engine for PHP based on Jade/Pug

8919.3k5](/packages/talesoft-tale-jade)[goetas/twital-bundle

Twital templating engine Symfony Bundle

206.8k](/packages/goetas-twital-bundle)

PHPackages © 2026

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