rilwanfit/yauaa-php
最新稳定版本:v1.1.0
Composer 安装命令:
composer require rilwanfit/yauaa-php
包简介
Yet Another User Agent Analyzer – a PHP implementation
README 文档
README
Yet Another User Agent Analyzer – PHP Edition
A lightweight and extensible PHP library for parsing and analyzing User-Agent strings, inspired by the original YAUAA (Java).
🙏 Special Thanks
This project is heavily inspired by the amazing work of Niels Basjes, author of the original Yet Another UserAgent Analyzer (YAUAA).
Without YAUAA, this PHP version wouldn't exist.
🚀 Features
- Detect browser (agent) name and version
- Detect layout engine [ToDo]
- Detect operating system and version [ToDo]
- Detect device class, brand, and name
- Basic bot detection support
- Pattern-driven and fully customizable (via YAML)
- No external dependencies required (except Symfony YAML parser)
🧰 Installation
composer require rilwanfit/yauaa-php
🧪 Example Usage
use Rilwanfit\YauaaPhp\Analyzer; $analyzer = new Analyzer(__DIR__ . '/resources/patterns.yaml'); $result = $analyzer->analyze('Mozilla/5.0 Chrome/117.0.0.0 Safari/537.36'); print_r($result); if ($analyzer->isMobile()) { echo "This is a mobile device."; } echo "Device class: " . $analyzer->getDeviceClass(); echo "Agent type: " . $analyzer->getAgentType();
📦 Custom Patterns
Patterns are loaded from a YAML file (resources/patterns.yaml). Example format:
browsers: - name: "Chrome" class: "Browser" pattern: "~Chrome/(?<version>[\\d\\.]+)~i" os: - name: "Windows" class: "Operating System" pattern: "~Windows NT (?<version>[\\d\\.]+)~i" device: - name: "Desktop" class: "Desktop" pattern: "~Windows NT~i"
✅ Testing
composer install ./vendor/bin/phpunit
🧱 Directory Structure
src/
Analyzer.php
resources/
patterns.yaml
tests/
AnalyzerTest.php
📄 License
This project is licensed under the MIT License.
👨💻 Author
Built by Rilwan Fit
统计信息
- 总下载量: 975
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-04-30