Yii2 extension for Mobile-Detect library

Installs: 664 246

Dependents: 4

Suggesters: 0

Security: 0

Stars: 136

Watchers: 11

Forks: 37

Open Issues: 2


0.0.12 2017-08-07 16:37 UTC

This package is not auto-updated.

Last update: 2024-06-08 15:59:23 UTC


Yii2 extension for Mobile-Detect library.

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

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

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: */

Or using the an alias:

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