devicedetect/devicedetectionlib
Composer 安装命令:
composer require devicedetect/devicedetectionlib
包简介
This is a device detection-identification library
关键字:
README 文档
README
About
Device Detect is a lightweight PHP class for detecting devices. It is based on mobiledetect library. It uses the User-Agent string combined with specific HTTP headers to identify devices (browser, os etc).
Install
As a composer package
composer require devicedetect/devicedetectionlib
or include the dependency in the composer.json file:
{
"require": {
"devicedetect/devicedetectionlib": "1.0.*"
}
}
Usage
<?php /** * Retrieve the User-Agent. * @method getUserAgent() * @return string|null The user agent if it's set. */ /** * Retrieve the list of known browsers. * @method getBrowsers() * @return array */ /** * Retrieve the list of operating systems. * @method getOperatingSystems() * @return array */ /** * Retrieve the list of device types. * @method getDeviceTypes() * @return array */ /** * Get device type. * @method getDeviceType($userAgent = null) * @param null $userAgent * @return string */ /** * Get device browser. * @method getBrowser() * @return string */ /** * Retrieve the User-Agent. * @method getOperatingSystem() * @return string */ /** * Mobile device detection. * @method isMobile($userAgent = null) * @param null $userAgent * @return bool */ /** * Tablet detection. * @method isTablet($userAgent = null) * @param null $userAgent * @return bool */ /** * Computer detection * @method isComputer($userAgent = null) * @param null $userAgent * @return bool */ /** * Ipad detection * @method isIpad() * @return bool */ /** * Iphone detection * @method isIphone() * @return bool */ /** * Android Os detection * @method isAndroid() * @return bool */ /** * Get version of os, browser etc * @method getVersion(string $key) * @param string $key * @return float|string */
Code example
Inject library into your code. Use as needed.
<?php namespace App\Http\Controllers; use App\Device_Detect; /** * Class DeviceDetectionController * * @package App\Http\Controllers */ class DeviceDetectionController extends Controller { /** * @var Device_Detect */ private $deviceDetect; /** * DeviceDetectionController constructor. * * @param $deviceDetect */ public function __construct(Device_Detect $deviceDetect) { $this->deviceDetect = $deviceDetect; } /** * Device Detection */ public function detect() { print_r($this->deviceDetect->getBrowser()); echo "\n"; print_r($this->deviceDetect->getOperatingSystem()); echo "\n"; print_r($this->deviceDetect->getDeviceType()); } }
devicedetect/devicedetectionlib 适用场景与选型建议
devicedetect/devicedetectionlib 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 18 次下载、GitHub Stars 达 5, 最近一次更新时间为 2019 年 10 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「device」 「device detect」 「Device detection」 「devicedetection」 「device detector」 「php device detect」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 devicedetect/devicedetectionlib 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 devicedetect/devicedetectionlib 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 devicedetect/devicedetectionlib 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shim repository for phpmd/phpmd
A Laravel 5 Package Provider to Identify/detect a user's browser, device, operating system and Language
Language detection in PSR-15 middleware
Platine User Agent is a lightweight library for detecting user browser, device, OS, CPU
MobileDetect library for YiiFramework 1.x
统计信息
- 总下载量: 18
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 5
- 点击次数: 6
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2019-10-04