dev-master
9999999-devDetect type of device by information from request
GPL-3.0+
The Requires
by DKeeper
extension yii2 mobile detect
Detect type of device by information from request
Detect type of device by information from request., (*1)
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)
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)
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();
Detect type of device by information from request
GPL-3.0+
extension yii2 mobile detect