karmendra/laravel-agent-detector 问题修复 & 功能扩展

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

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

karmendra/laravel-agent-detector

Composer 安装命令:

composer require karmendra/laravel-agent-detector

包简介

Laravel wrapper for matomo-org/device-detector user agent parser

README 文档

README

Latest Stable Version Total Downloads

A PHP desktop/mobile user agent parser for Laravel, based on Device Detector that will parse any User Agent and detect the browser, operating system, device used (desktop, tablet, mobile, tv, cars, console, etc.), brand and model.

Goto http://devicedetector.net for a quick demo of what this library can detect.

Installation

Install using composer:

composer require karmendra/laravel-agent-detector

Laravel (optional)

Add the service provider in config/app.php:

Karmendra\LaravelAgentDetector\AgentDetectorServiceProvider::class,

And add the AgentDetector alias to config/app.php:

'AgentDetector' => Karmendra\LaravelAgentDetector\Facades\AgentDetector::class,

Basic Usage

Start by creating an AgentDetector instance (or use the AgentDetector Facade):

use Karmendra\LaravelAgentDetector\AgentDetector;

$user_agent = 'Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2';
$ad = new AgentDetector($user_agent);

If you want set different user agents on the fly in CLI scripts for example, you can use the setUserAgent

$ad->setUserAgent('Mozilla/5.0 (Macintosh; Intel Mac OS X 10_6_8) AppleWebKit/537.13+ (KHTML, like Gecko) Version/5.1.7 Safari/534.57.2');

All of the original Device Detector methods are still available

Additional Functionality

Device type

Get the device type. (smartphone, mobile, tablet, desktop, bot ...)

$type = $ad->device();

Device brand name

Get the device manufactures brand name, if mobile. (Apple, Nexus, Samsung, ...)

$brand = $ad->deviceBrand();

Device model

Get the device model, if mobile. (Apple: iPhone, Samsung: Galaxy S9 ...)

$model = $ad->deviceModel();

Platform / Operating system name

Get the operating system. (Ubuntu, Android, Windows, Mac, iOS, ...)

$platform = $ad->platform();

Platform version (OS version).

Get the platform version. (Windows: 10, Mac: 10.11, Android: 9.0, ...)

$platform_version = $ad->platformVersion();

Browser name

Get the browser name. (Chrome, IE, Safari, UC Browser, ...)

$browser = $ad->browser();

Browser version

Get the browser name. (Chrome: 56, Safari: 9.0, Firefox: 48, ...)

$browser_version = $ad->browserVersion();

Robot detection

Check if the user is a robot. (true or false)

$ad->isBot();

To-do (PR welcome):

  • Adding test cases
  • Adding additional functions for getting robot info, enable disable robot detection etc.

License

Laravel Agent Detector is licensed under The MIT License (MIT).

karmendra/laravel-agent-detector 适用场景与选型建议

karmendra/laravel-agent-detector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 48.29k 次下载、GitHub Stars 达 12, 最近一次更新时间为 2020 年 02 月 17 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 karmendra/laravel-agent-detector 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

  • 总下载量: 48.29k
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 12
  • 点击次数: 25
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 12
  • Watchers: 1
  • Forks: 3
  • 开发语言: PHP

其他信息

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