Need help with yii2-device-detect?
Click the “chat” button below for chat support from the developer who created it, or find similar developers for support.

About the developer

alexandernst
129 Stars 38 Forks Other 36 Commits 2 Opened issues

Description

Yii2 extension for Mobile-Detect library

Services available

!
?

Need anything else?

Contributors list

# 109,044
HTML
footpri...
React
TypeScr...
24 commits
# 386,522
Shell
curl
Yii Fra...
yii2
2 commits
# 396,868
Shell
HTML
padrino
Rails
2 commits
# 699,694
PHP
1 commit
# 689,913
PHP
1 commit

yii2-device-detect

Yii2 extension for Mobile-Detect library.

To use it just require this extension in your

composer.json
file:
"alexandernst/yii2-device-detect": "0.0.12",

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'.

We use cookies. If you continue to browse the site, you agree to the use of cookies. For more information on our use of cookies please see our Privacy Policy.