定制 rubricate/agent 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

rubricate/agent

最新稳定版本:v3.0.0

Composer 安装命令:

composer require rubricate/agent

包简介

Dentifies the platform, browser, robot, or mobile device of the browsing agent

README 文档

README

Maintainer Source Code PHP from Packagist Latest Version Software License Total Downloads

Last Version

$ composer require rubricate/agent

Documentation is at https://rubricate.github.io/components/agent

Preparing the Configuration Data

<?php

$config = [
    'platforms' => [
        'windows nt 10.0' => 'Windows 10',
        'android'         => 'Android',
        'iphone'          => 'iPhone',
        'linux'   => 'Linux',
        'ubuntu'  => 'Ubuntu Linux',
        'fedora'  => 'Fedora Linux',
        'x11'     => 'Linux (Generic)'
    ],
    'browsers' => [
        'Chrome'  => 'Chrome',
        'Firefox' => 'Firefox',
        'MSIE'    => 'Internet Explorer',
    ],
    'mobiles' => [
        'iphone'   => 'Apple iPhone',
        'android'  => 'Android Device',
    ],
    'robots' => [
        'googlebot' => 'Googlebot',
    ]
];

Preparing the Configuration Data

<?php

use Rubricate\Agent\UserAgent;

// 1. Instantiate the class passing the configurations
$ua = new UserAgent($config);

// 2. Checking the device type
if ($ua->isMobile()) {
    echo "You are using a mobile device: " . $ua->getMobile();

} elseif ($ua->isRobot()) {
    echo "Hello, robot: " . $ua->getRobot();

} else {
    echo "You are on a Desktop.";
}

echo "<br>";

// 3. Obtaining specific browser information
if ($ua->isBrowser()) {
    echo "Browser: " . $ua->getBrowser() . " (Version: " . $ua->getVersion() . ")";
}

echo "<br>"; // 4. Checking the Platform (OS)
echo "Operating System: " . $ua->getPlatform();

echo "<br>";

/ 5. Accepted Languages
echo "Preferred Languages: " . implode(', ', $ua->getLanguages());

/ 6. Specific Boolean Check
if ($ua->acceptLang('pt-br')) {
    echo "The user accepts Brazilian Portuguese.";
}

Credits

License

The MIT License (MIT). Please see License File for more information.

统计信息

  • 总下载量: 50
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 0
  • 点击次数: 7
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 0
  • Watchers: 0
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2026-04-07

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固