lulubin/yii2-component-devicedetect

用于检测设备的Yii2组件

dev-main 2023-07-25 05:43 UTC

This package is auto-updated.

Last update: 2024-09-25 08:34:49 UTC


README

composer require --prefer-dist lulubin/yii2-component-devicedetect "dev-master"

2.配置

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

3.使用

var_dump(Yii::$app->params['devicedetect']);
array (size=3)
  'isMobile' => boolean false
  'isTablet' => boolean false
  'isDesktop' => boolean true
var_dump(Yii::$app->devicedetect->isMobile());
var_dump(Yii::$app->devicedetect->isTablet());
/*Check all available methods here: http://demo.mobiledetect.net/ */
var_dump(Yii::getAlias('@device')); //return 'mobile', 'tablet' or 'desktop'