manoj-malviya / yii2-device-detect
There is no license information available for the latest version (1.0.0) of this package.
Yii2 extension for Mobile-Detect library
Package info
github.com/manoj-malviya/yii2-device-detect
Type:yii2-extension
pkg:composer/manoj-malviya/yii2-device-detect
1.0.0
2026-01-07 07:26 UTC
Requires
This package is auto-updated.
Last update: 2026-03-07 07:54:08 UTC
README
Yii2 extension for Mobile-Detect library.
To use it just require this extension in your composer.json file:
"manoj-malviya/yii2-device-detect": "*",
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:
var_dump(Yii::$app->params['devicedetect']); 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*/ \Yii::$app->devicedetect->isMobile(); /*Detect a tablet device*/ \Yii::$app->devicedetect->isTablet(); /*Check all available methods here: http://demo.mobiledetect.net/ */
Or using the an alias:
\Yii::getAlias('@device'); //return 'mobile', 'tablet' or 'desktop'.