ustmaestro/yii2-mobile-detect

Yii2 移动检测组件

安装数: 1,164

依赖者: 0

推荐者: 0

安全性: 0

星星: 0

关注者: 3

分支: 0

公开问题: 0

类型:yii2-extension

1.0.0 2015-04-05 14:56 UTC

This package is not auto-updated.

Last update: 2024-09-14 16:18:46 UTC


README

MobileDetect Yii2 扩展

本扩展基于由 Serban Ghita 和 Victor Stanciu 编写的 Mobile_Detect 类

安装

安装此扩展的最佳方式是通过 composer

运行以下命令之一:

php composer.phar require --prefer-dist ustmaestro/yii2-mobile-detect "dev-master"

或添加

"ustmaestro/yii2-mobiledetect": "dev-master"

到你的 composer.json 文件的 require 部分。

例如,在 config/web.php 文件中添加你的组件:

'components' => [
    ...

    'mobileDetect' => [
        'class' => 'ustmaestro\mobiledetect\MobileDetect'
    ],
    
    ...
];

使用方法

  $detect = Yii::$app->mobileDetect;
  // call methods
  $detect->isMobile();
  $detect->isTablet();
  $detect->isIphone();
  ...