Skip to content

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

Notifications You must be signed in to change notification settings

tattali/MobileDetectBundle

Repository files navigation

Mobile Detect

MobileDetectBundle

Symfony 3.4.x-6.0.x bundle for detect mobile devices, manage mobile view and redirect to the mobile and tablet version.

Github Actions Status Total Downloads Latest Stable Version codecov

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

Introduction

This Bundle use Mobile_Detect 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, full)
  • Redirects to mobile and tablet sites

Documentation

Installation

composer require tattali/mobile-detect-bundle

Usage

Checking device

use MobileDetectBundle\DeviceDetector\MobileDetectorInterface;

public function someaction(MobileDetectorInterface $mobileDetector)
{
    $mobileDetector->isMobile();
    $mobileDetector->isTablet();
    $mobileDetector->is('iPhone');
}
{% if is_mobile() %}
{% if is_tablet() %}
{% if is_device('iPhone') %} # magic methods is[...]

Switch device view

For switch device view, use device_view GET parameter:

http://localhost:8000?device_view={full/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

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

About

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

Topics

Resources

Stars

Watchers

Forks

Languages

  • PHP 98.6%
  • Twig 1.3%
  • Makefile 0.1%