tattali/mobile-detect-bundle

Symfony 5.x-7.x bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.

Maintainers

πŸ‘ tattali

Package info

github.com/tattali/MobileDetectBundle

Type:symfony-bundle

pkg:composer/tattali/mobile-detect-bundle

Statistics

Installs: 1 142 885

Dependents: 1

Suggesters: 0

Stars: 38

Open Issues: 3

v7.0.0 2024-12-23 14:52 UTC

MIT f890ab900b968eb7d263c035b88852b07a98a6b4

  • ThΓ©o Attali <theoattali.woop@gmail.com>
  • Nikolay Ivlev <nikolay.kotovsky.woop@gmail.com>
  • Henri Vesala <henri.vesala.woop@gmail.com>
  • netmikey

symfonymobile detectmobile view managingdevice detectmobiledetectdevice detectormobiledetectbundlesymfony mobile detectsymfony mobiledetect


README

πŸ‘ Mobile Detect

MobileDetectBundle

Symfony 5.4.x-7.0 bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet version.

πŸ‘ Github Actions Status
πŸ‘ Latest Stable Version
πŸ‘ Packagist Downloads
πŸ‘ Coverage
πŸ‘ Packagist License
πŸ‘ Packagist Dependency Version

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 7x

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