i4erkasov/yii2-device-detect

Device Detect extension for Yii2

1.0 2019-09-21 08:37 UTC

This package is auto-updated.

Last update: 2022-07-21 16:11:42 UTC


README

Device Detect extension for Yii2"

Installation

The preferred way to install this extension is through composer.

Either run

php composer.phar require --prefer-dist i4erkasov/yii2-device-detect "*"

or add

"i4erkasov/yii2-device-detect": "*"

to the require section of your composer.json file.

Usage

Once the extension is installed, simply use it in your code by :

  1. Add mobileDetect component to your Yii2 configuration like this:

    'components' => [
        'device' => [
            'class' => '\i4erkasov\devicedetect\DeviceDetect'
        ]
    ]
  2. Use DeviceDetect component as Mobile_Detect PHP class:

    echo \Yii::$app->device->isMobile();
    echo \Yii::$app->device->isTablet();
    echo \Yii::$app->device->isDesktop();