backend2-plus/is-mobile-bundle

Check if site is started on Mobile or not

Installs: 343

Dependents: 0

Suggesters: 0

Security: 0

Stars: 0

Watchers: 2

Forks: 2

Open Issues: 1

Type:symfony-bundle

v1.0.8 2025-01-27 17:41 UTC

This package is auto-updated.

Last update: 2025-04-27 18:09:22 UTC


README

INSTALL:

composer req backend2-plus/is-mobile-bundle

Simple code for detecting device.

USE IN CONTROLLER:

use IsMobile\IsMobileBundle\IsMobile;

#[Route('/', name: 'app_home')]
public function index(IsMobile $isMobile): JsonResponse
{

    return $this->json([
        'isMobile' => $isMobile->isMobile()
    ]);
}

USE IN TWIG:

config/packages/twig.yaml:

globals:
    isMobileHelper: '@IsMobile\IsMobileBundle\IsMobile'

and you can use in twig template:

{% if isMobileHelper.IsMobile %}

{% endif %}