PHP code example of gulltour / mobiledetector

1. Go to this page and download the library: Download gulltour/mobiledetector library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

gulltour / mobiledetector example snippets


return [
    ...
    'components' => [
        'mobiledetect' => [
            'class' => 'gulltour\mobiledetect\MobileDetect',
        ],
    ],
    ...
];

// 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();

php composer.phar