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.
Installs: 555 520
Dependents: 1
Suggesters: 0
Security: 0
Stars: 35
Watchers: 2
Forks: 156
Open Issues: 5
Type:symfony-bundle
Requires
- php: >=8.2
- mobiledetect/mobiledetectlib: ^2.8.15
- symfony/dependency-injection: ^7.0
- symfony/event-dispatcher: ^7.0
- symfony/framework-bundle: ^7.0
- symfony/yaml: ^7.0
- twig/twig: ^2.0 || ^3.0
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.8
- phpstan/extension-installer: ^1.0
- phpstan/phpstan: ^1.0
- phpstan/phpstan-nette: ^1.0
- phpstan/phpstan-phpunit: ^1.0
- phpunit/phpunit: ^9.5
- squizlabs/php_codesniffer: ^3.6
- symfony/dotenv: ^7.0
- symfony/phpunit-bridge: ^7.0
This package is auto-updated.
Last update: 2024-12-21 15:18:23 UTC
README
MobileDetectBundle
Symfony 3.4.x-6.0.x bundle to detect mobile devices, manage mobile view and redirect to the mobile and tablet 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 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
Install with Symfony legacy versions: here
Usage
Checking device
use MobileDetectBundle\DeviceDetector\MobileDetectorInterface; public function someaction(MobileDetectorInterface $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:
http://localhost:8000?device_view={full/mobile/tablet}
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