2017 © Pedro Peláez
 

yii2-extension yii2-mobiledetect

Detect type of device by information from request

image

dkeeper/yii2-mobiledetect

Detect type of device by information from request

  • Tuesday, August 26, 2014
  • by DKeeper
  • Repository
  • 4 Watchers
  • 6 Stars
  • 9,212 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 5 Forks
  • 1 Open issues
  • 1 Versions
  • 2 % Grown

The README.md

Mobile detector

Detect type of device by information from request., (*1)

Notes

This extension based on mobiledetect project http://mobiledetect.net/., (*2)

See [here] (https://github.com/serbanghita/Mobile-Detect/) and [here] (http://demo.mobiledetect.net/) for more documentation and examples., (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist dkeeper/yii2-mobiledetect "*"

or add, (*6)

"dkeeper/yii2-mobiledetect": "*"

to the require section of your composer.json file., (*7)

Usage

Update config file config/web.php or common/main.php:, (*8)

return [
    ...
    'components' => [
        'mobiledetect' => [
            'class' => 'dkeeper\mobiledetect\Detect',
        ],
    ],
    ...
];

Set event handler for detect type of device before run Application, (*9)

// path/to/web/index.php
$application = new yii\web\Application($config);

Yii::$app->on(\yii\base\Application::EVENT_BEFORE_REQUEST,function($event){
    Yii::$app->params['detect'] = [
        'isMobile' => Yii::$app->mobiledetect->isMobile(),
        'isTablet' => Yii::$app->mobiledetect->isTablet(),
    ];
});

$application->run();

The Versions

26/08 2014

dev-master

9999999-dev

Detect type of device by information from request

  Sources   Download

GPL-3.0+

The Requires

 

by Avatar DKeeper

extension yii2 mobile detect