alexander-suter/yii2-browser-info

Browser Information for Yii2

Installs: 2 340

Dependents: 0

Suggesters: 0

Security: 0

Stars: 2

Watchers: 1

Forks: 0

Type:yii2-extension

2.0.2 2015-06-29 13:01 UTC

This package is not auto-updated.

Last update: 2024-10-26 18:06:33 UTC


README

Latest Stable Version Total Downloads Build Status Dependency Status Scrutinizer Quality Score

Yii2 extension. Provides detailed information about the browser.

Current available providers:

Installation

The preferred way to install this extension is through composer.

To install, either run

$ php composer.phar require alexander-suter/yii2-browser-info "*"

or add

"alexander-suter/yii2-browser-info": "*"

to the require section of your composer.json file.

Usage

This extensions works with a cache in the background. You have to update the cache from time to time.

Create a cronjob and execute following command:

./yii browser-info/update-cache

Use dependency injection to define the concret instance:

Yii::$container->set('asu\browserinfo\BrowserInfo', [
            'class' => 'asu\browserinfo\BrowserInfoBrowscap',
            'memoryLimit' => '512M' 
]);

The Browscap implementation needs much memory to update the cache.

To get browser information in a controller you can now use your DI-Definition:

class SiteController extends Controller {
      private $browserInfo = null;
      public function __construct($id, $module, BrowserInfo $browserInfo, $config = []) {
        $this->browserInfo = $browserInfo;
        parent::__construct($id, $module, $config);
      }
      public function actionIndex() {
        echo $this->browserInfo->getBrowserName();
      }
}