定制 valentinloiseau/ua-parser 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

valentinloiseau/ua-parser

Composer 安装命令:

composer require valentinloiseau/ua-parser

包简介

The missing UAParser PHP library.

README 文档

README

UAParser is a library which helps you to parse user agents and detect browser, operating system, device and more.

SensioLabsInsight

Basic Usage

<?php

// create a new UAParser instance
$uaParser = new \UAParser\UAParser();

// ...or optionally load a custom regexes.yml file of your choice
// $uaParser = new \UAParser\UAParser(__DIR__.'/../../custom_regexes.yml');

// parse a user agent string an get the result
$result =  $uaParser->parse('Mozilla/5.0 (Windows NT 6.1; WOW64; rv:23.0) Gecko/20130406 Firefox/23.0.1');

Results

Global Result API

  • $result->getBrowser() will return a UAParser\Result\BrowserResult object
  • $result->getOperatingSystem() will return a UAParser\Result\OperatingSystemResult object
  • $result->getDevice() will return a UAParser\Result\DeviceResult object
  • $result->getRenderingEngine() will return a UAParser\Result\RenderingEngineResult object
  • $result->getEmailClient() will return a UAParser\Result\EmailClientResult object

Browser

  • $result->getBrowser()->getFamily() will return a string like Firefox
  • $result->getBrowser()->getMajor() will return an integer like 23
  • $result->getBrowser()->getMinor() will return an integer like 0
  • $result->getBrowser()->getPatch() will return an integer like 1
  • $result->getBrowser()->getVersionString() will return a string like 23.0.1

Operating System

  • $result->getOperatingSystem()->getFamily() will return a string like Mac OS
  • $result->getOperatingSystem()->getMajor() will return a string like 10
  • $result->getOperatingSystem()->getMinor() will return a string like 8
  • $result->getOperatingSystem()->getPatch() will return a string like 4

Device

  • $result->getDevice()->getConstructor() will return a string like Apple
  • $result->getDevice()->getModel() will return a string like iPhone
  • $result->getDevice()->getType() will return a string like mobile
  • $result->getDevice()->isMobile() will return a boolean like true
  • $result->getDevice()->isTablet() will return a boolean like false
  • $result->getDevice()->isDesktop() will return a boolean like false
  • $result->getDevice()->is('mobile') will return a boolean like false
  • $result->getDevice()->is('tablet') will return a boolean like false
  • $result->getDevice()->is('desktop') will return a boolean like false

EmailClient

  • $result->getEmailClient()->getFamily() will return a string like Thunderbird
  • $result->getEmailClient()->getMajor() will return a string like 3
  • $result->getEmailClient()->getMinor() will return a string like 1
  • $result->getEmailClient()->getPatch() will return a string like 2
  • $result->getEmailClient()->getType() will return a string like desktop
  • $result->getEmailClient()->isDesktop() will return a boolean like true
  • $result->getEmailClient()->isWebmail() will return a boolean like false
  • $result->getEmailClient()->is('desktop') will return a boolean like true
  • $result->getEmailClient()->is('webmail') will return a boolean like false

Rendering Engine

  • $result->getRenderingEngine()->getFamily() will return a string like Trident
  • $result->getRenderingEngine()->getVersion() will return a string like 4.0

Unit Tests

To run unit tests, you'll need cURL and a set of dependencies you can install using Composer:

curl -sS https://getcomposer.org/installer | php
php composer.phar install

Once installed, just launch the following command:

./vendor/bin/phpunit

You're done.

Credits

Thanks for providing a huge amount of data to run tests:

License

UAParser is released under the MIT License. See the bundled LICENSE file for details.

valentinloiseau/ua-parser 适用场景与选型建议

valentinloiseau/ua-parser 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 510 次下载、GitHub Stars 达 0, 最近一次更新时间为 2020 年 02 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

它主要适用于以下技术方向: 「parser」 「browser」 「user agent」 「operating system」 「email client」 「plateform」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。

我们在过去多个企业项目中使用过 valentinloiseau/ua-parser 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 valentinloiseau/ua-parser 我们能提供哪些服务?
定制开发 / 二次开发

基于 valentinloiseau/ua-parser 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

  • 总下载量: 510
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 13
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 23
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-02-19