Search by

tattali / mobile-detect-bundle

tattali

Symfony 8 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.

Package info

github.com/tattali/MobileDetectBundle

Type:symfony-bundle

pkg:composer/tattali/mobile-detect-bundle

Statistics

Installs: 1 302 127

Dependents: 1

Suggesters: 0

Stars: 38

Open Issues: 1

v8.1.0 2026-10-18 22:19 UTC

README

Mobile Detect

MobileDetectBundle

CI Quality Gate Coverage Latest Version Downloads PHP Symfony License

Symfony 8 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.

Each major version of the bundle supports one Symfony major version. main gets the new features; the older branches get bug fixes only.

Bundle Symfony PHP Branch
8.x 8 8.4+ main
7.x 7 8.2+ 7.x
6.x 6.4 8.1+ 6.x
5.x 5.4 7.2.5+ 5.x (security fixes only)

For older Symfony versions, see legacy versions.

This bundle is a fork of suncat2000/MobileDetectBundle. As this project doesn't look maintained anymore, we decided to create & maintain a fork. For more information read our manifest.

Introduction

This Bundle use MobileDetect class and provides the following features:

  • Detect the various mobile devices by Name, OS, browser User-Agent

  • Manages site views for the various mobile devices (mobile, tablet, desktop)

  • Redirects to mobile and tablet sites

  • Migrate to 8x

  • Migrate to 7x

  • Changelog

Documentation

Installation

composer require tattali/mobile-detect-bundle

Install with Symfony legacy versions: here

Usage

Checking device

use Detection\MobileDetect;

public function someaction(MobileDetect $mobileDetector)
{
    $mobileDetector->isMobile();
    $mobileDetector->isTablet();
    $mobileDetector->is('iPhone');
}

With Twig

{% if is_mobile() %}
{% if is_tablet() %}
{% if is_device('iPhone') %} # magic methods is[...]

Available User-Agents (uaMatch) with the php is() and twig is_device() here

Switch device view

For switch device view, use device_view GET parameter:

https://localhost:8000?device_view={desktop/mobile/tablet}

Or using the Symfony toolbar mbd-bundle-sf-toolbar

Going further

Contribute and feedback

Any feedback and contribution will be very appreciated.

License and credits

This bundle is under the MIT license. See the complete license in the bundle

Original authors: suncat2000, HenriVesala, netmikey and all contributors