PHPackages                             polifonic/twig-validator-extension - 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. polifonic/twig-validator-extension

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

polifonic/twig-validator-extension
==================================

A Twig extension to validate objects inside a Twig template

1.0.3(9y ago)38.6k1MITPHPPHP &gt;=5.5.9

Since Oct 26Pushed 9y ago1 watchersCompare

[ Source](https://github.com/polifonic/twig-validator-extension)[ Packagist](https://packagist.org/packages/polifonic/twig-validator-extension)[ Docs](https://github.com/polifonic/twig-validator-extension)[ RSS](/packages/polifonic-twig-validator-extension/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (5)Used By (0)

Twig Validator Extension
========================

[](#twig-validator-extension)

A simple Twig extension that adds a `valid` filter to be used in twig templates.

With this filter you can test if objects are valid inside a twig template and generate the appropriate markup based on the result.

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

[](#installation)

Add the package to your app's `composer.json`:

```
	"require": {

	    "polifonic/twig-validator-extension": "^1.0",
	}
```

### As a Twig Extension

[](#as-a-twig-extension)

Create an instance of `TwigValidatorExtension` and add it to the Twig environment just like any other twig extension.

The `TwigValidatorExtension` constructor needs to be passed a validator (an instance of `Symfony\Component\Validator\Validator\ValidatorInterface`).

```
use Polifonic\Twig\Extension\Validator\TwigValidatorExtension;

$validator = ...;

$twig = new Twig_Environment($loader);

$twig->addExtension(new TwigValidatorExtension($validator));
```

### As a Symfony bundle

[](#as-a-symfony-bundle)

The package includes a Symfony bundle named `TwigValidatorBundle`. This bundle will automatically add the `TwigValidatorExtension` to twig.

Enable the `TwigValidatorBundle` symfony bundle by adding it to your app's kernel:

```
# app/AppKernel.php

public function regsiterBundles()
{
	$bundles = array(
		...
        new Polifonic\Twig\Extension\Validator\Symfony\TwigValidatorBundle(),
	);
}
```

Usage
-----

[](#usage)

```
{% if object|valid %}...{% endif %}
```

With validation groups:

```
{% if object|valid([ "group1", "group2" ]) %}...{% endif %}
```

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 92.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 ~3 days

Total

4

Last Release

3525d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/61710b3e2bdf8cc378cb14f7e9c3d4fa753738373565270820a7be21c89f6d69?d=identicon)[opichon](/maintainers/opichon)

---

Top Contributors

[![opichon](https://avatars.githubusercontent.com/u/203745?v=4)](https://github.com/opichon "opichon (13 commits)")[![coudenysj](https://avatars.githubusercontent.com/u/96260?v=4)](https://github.com/coudenysj "coudenysj (1 commits)")

---

Tags

symfonyvalidatortwig

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/polifonic-twig-validator-extension/health.svg)

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

###  Alternatives

[symfony/ux-twig-component

Twig components for Symfony

22017.2M313](/packages/symfony-ux-twig-component)[symfony/ux-live-component

Live components for Symfony

1636.5M115](/packages/symfony-ux-live-component)[tales-from-a-dev/twig-tailwind-extra

A Twig extension for Tailwind

36982.8k12](/packages/tales-from-a-dev-twig-tailwind-extra)[yellowskies/qr-code-bundle

Symfony Barcode &amp; QR Code Generator Bundle with Twig extension

36701.5k](/packages/yellowskies-qr-code-bundle)[boekkooi/jquery-validation-bundle

Jquery form validation bundle for symfony 2

2773.9k1](/packages/boekkooi-jquery-validation-bundle)[mati365/ckeditor5-symfony

CKEditor 5 integration for Symfony

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

PHPackages © 2026

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