Yii2 extension for Mobile-Detect library
Latest commit 82b520e May 4, 2016 @alexandernst Release 0.0.11
Failed to load latest commit information.
DeviceDetect.php Fix #7 May 4, 2016
LICENSE Chance license Apr 22, 2015
README.md Release 0.0.11 May 4, 2016
composer.json Less restrictive dependency Apr 22, 2015



Yii2 extension for Mobile-Detect library.

To use it just require this extension in your composer.json file:

"alexandernst/yii2-device-detect": "0.0.11",

And then add it to your components configuration in Yii2:

'bootstrap' => ['devicedetect'],
'components' => [
    'devicedetect' => [
        'class' => 'alexandernst\devicedetect\DeviceDetect'

Some basic detections are available in Yii's params:


array (size=3)
  'isMobile' => boolean false
  'isTablet' => boolean false
  'isDesktop' => boolean true

You can also use it from anywhere in your code, calling Mobile-Detect's API:

/*Detect a mobile device*/

/*Detect a tablet device*/

/*Check all available methods here: http://demo.mobiledetect.net/ */

Or using the an alias:

\Yii::getAlias('@device'); //return 'mobile', 'tablet' or 'desktop'.