PHPackages                             bes/mobiledetect-twig-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. bes/mobiledetect-twig-extension

ActiveTwig-extension[Templating &amp; Views](/categories/templating)

bes/mobiledetect-twig-extension
===============================

MobileDetect-integration for Twig

v1.0.3(8y ago)18238.9k↓48.1%8[1 issues](https://github.com/bes89/mobiledetect-twig-extension/issues)[1 PRs](https://github.com/bes89/mobiledetect-twig-extension/pulls)MITPHPPHP &gt;=5.3.0

Since Oct 7Pushed 3y ago2 watchersCompare

[ Source](https://github.com/bes89/mobiledetect-twig-extension)[ Packagist](https://packagist.org/packages/bes/mobiledetect-twig-extension)[ Docs](https://github.com/bes89/mobiledetect-twig-extension)[ RSS](/packages/bes-mobiledetect-twig-extension/feed)WikiDiscussions master Synced 2d ago

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

mobiledetect-twig-extension
===========================

[](#mobiledetect-twig-extension)

"Mobile Detect" integration for Twig

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

[](#installation)

```
composer require "bes/mobiledetect-twig-extension:1.*"
```

And register the extension:

**Twig standalone**

```
    $twig->addExtension(new Bes\Twig\Extension\MobileDetectExtension());
```

**Silex**

Yay, you don't need a ServiceProvider for it!

Add the following code after registering TwigServiceProvider:

```
    $app['twig'] = $app->share($app->extend('twig', function($twig) {
        /* @var $twig \Twig_Environment */
        $twig->addExtension(new Bes\Twig\Extension\MobileDetectExtension);
        return $twig;
    }));
```

... and you are done!

**Symfony3**

Yay, you don't need a Bundle for it!

Add the following code to one of your services.yml, e.g. `src//Bundle/Resources/config/services.yml` or globally in `app/config/config.yml`:

```
    services:
        twig.mobile_detect_extension:
            class: Bes\Twig\Extension\MobileDetectExtension
            tags:
                - { name: twig.extension }
```

... and you are done!

Examples
--------

[](#examples)

Render different layouts:

```
{% extends is_mobile() ? "layout_mobile.html.twig" : "layout.html.twig" %}
```

Check device type:

```
{% if is_mobile() %} ... {% endif %}
{% if is_tablet() %} ... {% endif %}
```

Or:

```
{% if is_mobile() and is_samsung() %} ... {% endif %}
```

You can get a list of all the known devices with:

```
    {{ get_available_devices()|join("")|raw }}
```

###  Health Score

38

—

LowBetter than 83% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity42

Moderate usage in the ecosystem

Community13

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 94.1% 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 ~497 days

Total

4

Last Release

3162d ago

### Community

Maintainers

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

---

Top Contributors

[![bes89](https://avatars.githubusercontent.com/u/1302733?v=4)](https://github.com/bes89 "bes89 (16 commits)")[![defragmentator](https://avatars.githubusercontent.com/u/11047379?v=4)](https://github.com/defragmentator "defragmentator (1 commits)")

---

Tags

mobilemobile detecttwig-extensionmobile-detectiontwig mobiletwig mobile extension

### Embed Badge

![Health badge](/badges/bes-mobiledetect-twig-extension/health.svg)

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

###  Alternatives

[craftcms/cms

Craft CMS

3.6k3.6M3.1k](/packages/craftcms-cms)[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)
