dungeonworx/laravel-devicedetector
Composer 安装命令:
composer require dungeonworx/laravel-devicedetector
包简介
Integration with DeviceDetector and Laravel.
README 文档
README
This package was created out of a need to integrate Piwik's DeviceDetector package into my Laravel application in a specific way. After working on the code in my project, I realized this package would be best suited to be a package and committed publicly for consumption.
The goal of this project is to provide easier access to the DeviceDetector library and also wrap it in an easy to use Laravel Facade to facilitate seamless access in other areas of the code. This library also provides a middleware which provides some additional information in your request payload to modify parts of your application based on the device that is currently connected.
Usage
Facade
If you include the middleware in your requests, you only need to use the Facade's methods, which are documented.
If you do not use the middleware in your request, or you wish to check a different user agent, you will need to pass the
optional user_agent parameter to the specific method. Please note, this changes the parsed results for all future
requests as well. So if you wish to go back to returning value for the current browser request, you will need to call
DeviceDetector::get($request->userAgent()) once more to reset back to the current browsing session.
use Dungeonworx\DeviceDetector\DeviceDetector; // Dump the DeviceDetector attributes to the client. dd(DeviceDetector::getAttributes());
[
"browser" => true,
"camera" => false,
"car" => false,
"console" => false,
"desktop" => true,
"feature_phone" => false,
"feed_reader" => false,
"library" => false,
"media_player" => false,
"mobile_app" => false,
"mobile_device" => false,
"phone_tablet" => false,
"pim" => false,
"portable_media_player" => false,
"smart_display" => false,
"smart_phone" => false,
"tablet" => false,
"touch_enabled" => false,
"tv" => false,
]
Middleware
To use this package in your middleware, just add the device_detector middleware alias to your web middleware in the
Http/Kernel.php file in your project. Once that's installed, you can access the four included detectors in your
request. The is key in the request contains an array with four booleans; bot, desktop, mobile, and touch. These
booleans are available for every request and also cached to your already assigned cache repository.
// Get the booleans from DeviceDetector. $request->get('is');
[
'bot' => false,
'desktop' => true,
'mobile' => false,
'touch' => false,
]
Documentation
This package is documented using phpDocumentor and it's API documentation can be located here.
dungeonworx/laravel-devicedetector 适用场景与选型建议
dungeonworx/laravel-devicedetector 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 179 次下载、GitHub Stars 达 9, 最近一次更新时间为 2018 年 12 月 23 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「user-agent」 「laravel」 「laravel-package」 「laravel-middleware」 「user-agent-parser」 「laravel-facade」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 dungeonworx/laravel-devicedetector 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 dungeonworx/laravel-devicedetector 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 dungeonworx/laravel-devicedetector 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Detect user Browser, OS and Device through Browser USER AGENT
Platine User Agent is a lightweight library for detecting user browser, device, OS, CPU
A Laravel package for converting English numbers into Bangla digits, Bangla words, Bangla month names, and Bangla money format with an easy-to-use API.
Laravel table comments loader (part of Diplodocker project)
Official PHP SDK for the IPGeolocation.io IP Location API with single and bulk lookup support.
Parses a user agent string to detect Internet Explorer
统计信息
- 总下载量: 179
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 9
- 点击次数: 5
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-12-23