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

ActiveSymfony-bundle[Templating &amp; Views](/categories/templating)

lelyfoto/twig-instanceof
========================

Adds InstanceOf Expression as Twig Extension

v1.3(2mo ago)881.2k↓30%4[1 issues](https://github.com/lelyfoto/twig-instanceof/issues)MITPHPPHP ^8.0

Since Feb 11Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/lelyfoto/twig-instanceof)[ Packagist](https://packagist.org/packages/lelyfoto/twig-instanceof)[ Docs](https://github.com/lelyfoto/twig-instanceof)[ RSS](/packages/lelyfoto-twig-instanceof/feed)WikiDiscussions main Synced yesterday

READMEChangelog (4)Dependencies (4)Versions (5)Used By (0)

Twig InstanceOf Expression
==========================

[](#twig-instanceof-expression)

[![Package version](https://camo.githubusercontent.com/b0c09567e4d57c4f9dec8a9173f4c38a1e3c8b8da3c869d89ffe0a9b990410b0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c656c79666f746f2f747769672d696e7374616e63656f662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lelyfoto/twig-instanceof)[![PHP version](https://camo.githubusercontent.com/5a6691d0ab756d0a5310e927a70b2356214529909726eb215fb347b5bc22b27a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6c656c79666f746f2f747769672d696e7374616e63656f662e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/lelyfoto/twig-instanceof)[![License](https://camo.githubusercontent.com/4632c729b2677c0be5cdf20c05505d79a16b253ae7518033cf998ab37c366bda/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6c656c79666f746f2f747769672d696e7374616e63656f662e7376673f7374796c653d666c61742d737175617265)](LICENSE)

Adds InstanceOf Expression as Twig Extension. When you want to check for a specific type of variable in a twig template.

Prerequisites
-------------

[](#prerequisites)

- PHP 8.0+
- Symfony 5.4, 6.x, 7.x or 8.x
- Twig 3.x

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

[](#installation)

1. Install this Symfony bundle with composer: ```
    composer require lelyfoto/twig-instanceof
    ```
2. Make sure the bundle is added to `config/bundles.php`: ```
    return [
        // ...
        Lelyfoto\Twig\InstanceOf\TwigInstanceOfBundle::class => ['all' => true],
        // ...
    ];

    ```

Usage
-----

[](#usage)

Important to note that when testing for a class that you must use quotes and escaping inside the twig templates.

```
{% if testObject is instanceof('\\Example\\TestInterface') %}
    Do something with {{ testObject.show() }}
{% endif %}
```

Use without Symfony
-------------------

[](#use-without-symfony)

```
use Twig\Environment;
use Lelyfoto\Twig\InstanceOf\InstanceOfExtension;

$twig = new Environment($loader);
$twig->addExtension(new InstanceOfExtension());
```

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance86

Actively maintained with recent releases

Popularity38

Limited adoption so far

Community14

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 70% 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 ~513 days

Total

4

Last Release

62d ago

### Community

Maintainers

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

---

Top Contributors

[![erkens](https://avatars.githubusercontent.com/u/10248696?v=4)](https://github.com/erkens "erkens (7 commits)")[![ceponcet](https://avatars.githubusercontent.com/u/25478284?v=4)](https://github.com/ceponcet "ceponcet (1 commits)")[![Copilot](https://avatars.githubusercontent.com/in/1143301?v=4)](https://github.com/Copilot "Copilot (1 commits)")[![petervanderwal](https://avatars.githubusercontent.com/u/19531172?v=4)](https://github.com/petervanderwal "petervanderwal (1 commits)")

---

Tags

bundleinstanceofphpsymfonysymfony-bundletwigsymfonytwiginstanceof

### Embed Badge

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

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[symfony/ux-toolkit

A tool to easily create a design system in your Symfony app with customizable, well-crafted Twig components

16126.1k1](/packages/symfony-ux-toolkit)[tales-from-a-dev/twig-tailwind-extra

A Twig extension for Tailwind

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

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

37711.6k](/packages/yellowskies-qr-code-bundle)[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[mati365/ckeditor5-symfony

CKEditor 5 integration for Symfony

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

PHPackages © 2026

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