alexander-suter/yii2-browser-info
最新稳定版本:2.0.2
Composer 安装命令:
composer require alexander-suter/yii2-browser-info
包简介
Browser Information for Yii2
README 文档
README
Yii2 extension. Provides detailed information about the browser.
Current available providers:
- Browscap (https://github.com/browscap/browscap-php)
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(); } }
统计信息
- 总下载量: 2.36k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 2
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: BSD-3-Clause
- 更新时间: 2015-05-22