Detectando el dispositivo en Symfony con MobileDetectBundle

Instalación del Bundle

composer require suncat/mobile-detect-bundle
<?phppublic function registerBundles(){$bundles = [     // ...
new SunCat\MobileDetectBundle\MobileDetectBundle(),

Ejemplo de uso

$mobileDetector = $this->get(‘mobile_detect.mobile_detector’);if($mobileDetector->isTablet()){// soy una tablet}else if($mobileDetector->isMobile()){// soy un movil}
{% if is_mobile() %}<h1>Movil</h1>{% endif %}{% if is_ios() %}<h1>Dispositivo iOS</h1>{% endif %}
is_enabled: true
status_code: 301
action: redirect
tablet: ~
switch_device_view: ~

Caso de Uso



Full Stack Web Developer —

Love podcasts or audiobooks? Learn on the go with our new app.

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store