PHPackages                             byjg/jinja-php - 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. byjg/jinja-php

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

byjg/jinja-php
==============

Lightweight PHP implementation of the Jinja2 template engine originally developed for Python

6.0.0(6mo ago)1747.1k↓37.1%4[1 issues](https://github.com/byjg/php-jinja/issues)4MITPHPPHP &gt;=8.3 &lt;8.6CI failing

Since May 21Pushed 3mo ago1 watchersCompare

[ Source](https://github.com/byjg/php-jinja)[ Packagist](https://packagist.org/packages/byjg/jinja-php)[ GitHub Sponsors](https://github.com/byjg)[ RSS](/packages/byjg-jinja-php/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (4)Dependencies (2)Versions (7)Used By (4)

   sidebar\_key jinja   tags    php

 text-manipulation

 template

    Jinja for PHP
=============

[](#jinja-for-php)

Lightweight PHP implementation of the [Jinja2](https://jinja.palletsprojects.com/) template engine originally developed for Python.

[![Sponsor](https://camo.githubusercontent.com/fab14b7f7f475072ada0473f193d6f322561fd4a2958e0cc89910d053347cf27/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f53706f6e736f722d2532336561346161613f6c6f676f3d67697468756273706f6e736f7273266c6f676f436f6c6f723d7768697465266c6162656c436f6c6f723d306431313137)](https://github.com/sponsors/byjg)[![Build Status](https://github.com/byjg/php-jinja/actions/workflows/phpunit.yml/badge.svg?branch=master)](https://github.com/byjg/php-jinja/actions/workflows/phpunit.yml)[![Opensource ByJG](https://camo.githubusercontent.com/425c1bbccc0f292bf4d20569ae74a6b2e384fd648f1af8911bc61de9a8dcfc0b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6f70656e736f757263652d62796a672d737563636573732e737667)](http://opensource.byjg.com)[![GitHub source](https://camo.githubusercontent.com/88e61eb211719144efdd570290a0456b6e13099c2df8d973f1bb43fe33bf0039/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4769746875622d736f757263652d696e666f726d6174696f6e616c3f6c6f676f3d676974687562)](https://github.com/byjg/php-jinja/)[![GitHub license](https://camo.githubusercontent.com/512ee2ec7dac8d89af2ddd276a50bcb05dafac06d85964ff7476fcd064439b8a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f62796a672f7068702d6a696e6a612e737667)](https://opensource.byjg.com/opensource/licensing.html)[![GitHub release](https://camo.githubusercontent.com/66660bd68223962fe49ceab6cb3797ef1510aa3c23fc87feb0841dc40e5707d1/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f62796a672f7068702d6a696e6a612e737667)](https://github.com/byjg/uri/releases/)

Overview
--------

[](#overview)

This library allows you to seamlessly process Jinja templates in PHP applications. It provides a familiar syntax for those coming from Python while offering a native PHP implementation.

### Key Features

[](#key-features)

- **Python Compatibility**: Process the same Jinja templates in both Python and PHP
- **Variable Support**: Full support for variables, properties, and nested structures
- **Conditional Logic**: `if`/`else` statements for conditional rendering
- **Loops**: Iterate over arrays and objects with `for` loops
- **Filters**: Transform output with built-in filters like `upper`, `lower`, `default`, etc.
- **Flexible Loaders**: Load templates from strings or the filesystem
- **Undefined Variable Handling**: Different strategies for handling undefined variables
- **Expressions**: Support for mathematical operations, comparisons, and concatenation

Usage
-----

[](#usage)

```
use ByJG\JinjaPhp\Template;
use ByJG\JinjaPhp\Undefined\DebugUndefined;

$templateString =  'World'
];
echo $template->render($variables);
```

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

[](#documentation)

The detailed documentation is organized as follows:

1. [Basic Usage](docs/basic-usage.md)
2. [Template Syntax](docs/template-syntax.md)
3. [Loaders](docs/loaders.md)
4. [Undefined Variables](docs/undefined-variables.md)
5. [Filters](docs/filters.md)
6. [Control Structures](docs/control-structures.md)
7. [Advanced Topics](docs/advanced-topics.md)
8. [API Reference](docs/api.md)
9. [PHP Jinja vs Python Jinja2 Comparison](docs/comparison.md)

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

[](#installation)

```
composer require byjg/jinja-php
```

Dependencies
------------

[](#dependencies)

 ```
flowchart TD
    byjg/jinja-php
```

      Loading ---

[Open source ByJG](http://opensource.byjg.com)

###  Health Score

53

—

FairBetter than 96% of packages

Maintenance74

Regular maintenance activity

Popularity40

Moderate usage in the ecosystem

Community18

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 96.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

Every ~183 days

Recently: every ~123 days

Total

6

Last Release

200d ago

Major Versions

4.9.1 → 5.0.x-dev2024-10-27

5.0.0 → 6.0.02025-11-22

PHP version history (3 changes)4.9.1PHP &gt;=7.4

5.0.x-devPHP &gt;=8.1 &lt;8.4

6.0.0PHP &gt;=8.3 &lt;8.6

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/981924?v=4)[Joao Gilberto Magalhaes](/maintainers/byjg)[@byjg](https://github.com/byjg)

---

Top Contributors

[![byjg](https://avatars.githubusercontent.com/u/981924?v=4)](https://github.com/byjg "byjg (62 commits)")[![sevrugin](https://avatars.githubusercontent.com/u/4169835?v=4)](https://github.com/sevrugin "sevrugin (1 commits)")[![Vitexus](https://avatars.githubusercontent.com/u/2621130?v=4)](https://github.com/Vitexus "Vitexus (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPsalm

Type Coverage Yes

### Embed Badge

![Health badge](/badges/byjg-jinja-php/health.svg)

```
[![Health](https://phpackages.com/badges/byjg-jinja-php/health.svg)](https://phpackages.com/packages/byjg-jinja-php)
```

###  Alternatives

[limenius/react-bundle

Client and Server-side react rendering in a Symfony Bundle

3861.2M](/packages/limenius-react-bundle)[wmde/php-vuejs-templating

PHP implementation of Vue.js templating engine

3041.6k2](/packages/wmde-php-vuejs-templating)[jelix/wikirenderer

WikiRenderer is a library to generate HTML or anything else from wiki content.

1712.2k1](/packages/jelix-wikirenderer)[webkinder/sproutset

A Composer package for handling responsive images in Roots Bedrock + Sage + Blade projects.

291.8k](/packages/webkinder-sproutset)

PHPackages © 2026

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