This extension adds support for PhpUserAgent(https://github.com/donatj/PhpUserAgent) to the Yii2 framework.
'components' => [
...
'userAgentParser' => [
'class' => 'yii\useragentparser\UserAgentParser',
'nameHttpPropertyUserAgent' => 'HTTP_USER_AGENT'
],
...
],
If we parse current request
$userAgentInfo = Yii::$app->userAgentParser->getUserAgentObject();
or need parse isset user-agent
$userAgentInfo = Yii::$app->userAgentParser->getUserAgentObject($userAgent);
$userAgentInfo it's UserAgentObject with properties:
- userAgent
- platform
- browser
- version
Add to Yii.php in root for autocompletion for custom components.
/** @property \yii\useragentparser\UserAgentParser $userAgentParser */
About autocompletion for custom components.
https://github.com/samdark/yii2-cookbook/blob/master/book/ide-autocompletion.md