teckhouse/mdetect-bundle

Mobile device detector bundle for Symfony2 (MDetect Wrapper)

dev-master 2013-10-03 17:46 UTC

This package is not auto-updated.

Last update: 2024-03-25 11:33:43 UTC


README

Add TeckHouseMDetectBundle in your composer.json:

{
    "require": {
        "teckhouse/mdetect-bundle": "dev-master"
    }
}

Install the bundle with composer:

$ php composer.phar update teckhouse/mdetect-bundle

Enable the bundle

<?php
// app/AppKernel.php

public function registerBundles()
{
    $bundles = array(
        
        // Yours bundles
        // [...] 

        // Mobile Detect Bundle
        new TeckHouse\MDetectBundle\TeckHouseMDetectBundle(),
    );
}

Configure

there is only one parameter :)

in config.yml:

teckhouse_mdetect:
    inject_value: [ true | false ]

Usage

if the injection in request is setted to true you will find the var "$userDeviceType" in request parameters bug that indentify the device type: "mobile", "tablet", "desk".

To get the value simple do this:

$request->server->get("userDeviceType");

If the injection is setted to "off" you can use the service to get infos about the device:

$this->get('teckhouse_mdetect.wrapper');

In any case you can use Twig filter extension to retrive the status in template:

{{ getDeviceType() }}