wolfcast/browser-detection 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

wolfcast/browser-detection

Composer 安装命令:

composer require wolfcast/browser-detection

包简介

The Wolfcast BrowserDetection PHP class facilitates the identification of the user's environment such as Web browser, version, platform family, platform version or if it's a mobile device or not.

README 文档

README

The Wolfcast BrowserDetection PHP class facilitates the identification of the user's environment such as Web browser, version, platform family, platform version or if it's a mobile device or not.

This class will try to detect what the user is using from the HTTP_USER_AGENT string sent by the Web browser. A good way to use the class would be to gather user statistics or to report the browser and version used for informational purposes. A bad way to use the class would be to serve content based on the browser and version used. Sites that rely on the user-agent string should be updated to modern techniques, such as feature detection, adaptive layout, and other modern practices.

Always keep in mind that HTTP_USER_AGENT can be easily spoofed by the user.

Features

The Wolfcast BrowserDetection PHP class is the most accurate detection class. It has been tested with 14000+ different user agent strings and it have a 99.95% accuracy ratio!

Natively detects the following browsers:

  • Android
  • BlackBerry
  • BlackBerry Tablet OS
  • Chrome
  • Edge
  • Firebird
  • Firefox
  • GNU IceCat
  • GNU IceWeasel
  • iCab
  • Internet Explorer
  • Internet Explorer Mobile
  • Konqueror
  • Lynx
  • Mozilla
  • MSN TV
  • Netscape
  • Nokia Browser
  • Opera
  • Opera Mini
  • Opera Mobile
  • Phoenix
  • Safari
  • Samsung Internet
  • UC Browser

You can also easily add custom rules to support other browsers not natively supported!

Natively detects the following robots:

  • Bingbot
  • Googlebot
  • MSNBot
  • W3C Validator
  • Yahoo! Multimedia
  • Yahoo! Slurp

You can also easily add custom rules to support other robots not natively supported!

Natively detects the following platforms:

  • Android
  • BlackBerry
  • Chrome OS
  • FreeBSD
  • iOS
  • Linux
  • Macintosh
  • NetBSD
  • Nokia
  • OpenBSD
  • OpenSolaris
  • Symbian
  • Windows
  • Windows CE
  • Windows Phone

You can also easily add custom rules to support other platforms not natively supported!

Requirements

Requires PHP 5.3 or newer (tested with PHP 8.4.5, 7.4.33 and 5.6.40).

Demo and full documentation

You can try the live demo of the class and you can read the documentation.

Installation

You can add this library as a local, per-project dependency to your project using Composer (Packagist link):

composer require wolfcast/browser-detection

You can also manually install this library by adding BrowserDetection.php (found in the lib directory) to your project and then require_once the library where needed.

Usage

require_once('BrowserDetection.php');

$browser = new Wolfcast\BrowserDetection();
if ($browser->getName() == Wolfcast\BrowserDetection::BROWSER_FIREFOX &&
    $browser->compareVersions($browser->getVersion(), '5.0') >= 0) {
    echo 'You are using FireFox version 5 or greater.';
}

History

Correctly identifying what Web browser your users are using is an incredibly complex task. If you ever tried to implement something like this you quickly saw how this can become a code mess. Only a few libraries exist and they often get deprecated and becomes abandonware. This is why we created our own detection engine. We didn't start from scratch. The class is a heavily updated version of Chris Schuld's Browser class version 1.9 (which was unmaintained for a couple of years). Chris' class was based on the original work from Gary White.

License

SPDX-License-Identifier: MIT OR LGPL-3.0-only

wolfcast/browser-detection 适用场景与选型建议

wolfcast/browser-detection 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 1.09M 次下载、GitHub Stars 达 139, 最近一次更新时间为 2016 年 08 月 01 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 wolfcast/browser-detection 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 1.09M
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 141
  • 点击次数: 41
  • 依赖项目数: 9
  • 推荐数: 0

GitHub 信息

  • Stars: 139
  • Watchers: 21
  • Forks: 58
  • 开发语言: PHP

其他信息

  • 授权协议: LGPL-3.0-or-later
  • 更新时间: 2016-08-01