承接 acsiomatic/device-detector-bundle 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

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

acsiomatic/device-detector-bundle

Composer 安装命令:

composer require acsiomatic/device-detector-bundle

包简介

Symfony Bundle for https://github.com/matomo-org/device-detector

README 文档

README

The AcsiomaticDeviceDetectorBundle provides integration of the DeviceDetector library into the Symfony framework.

DeviceDetector is a Universal Device Detection library that parses User Agents and Browser Client Hints to detect devices (desktop, tablet, mobile, tv, cars, console, etc.), clients (browsers, feed readers, media players, PIMs, ...), operating systems, brands and models.

From https://github.com/matomo-org/device-detector

This bundle provides the DeviceDetector class as service, and Twig global variable.

Installation

You can install the bundle using Composer:

composer require acsiomatic/device-detector-bundle

Configuration

You can configure the bundle using the acsiomatic_device_detector configuration section:

# config/packages/acsiomatic_device_detector.yaml

acsiomatic_device_detector:

    # If true, DeviceDetector will trigger parser() when necessary
    auto_parse: true

    # Version truncation behavior, it may assume: major, minor, patch, build, or none
    # By default minor versions will be returned (e.g. X.Y)
    version_truncation: 'minor'

    cache:

        # If null, it will disable caching
        pool: 'cache.app'

    bot:

        # If true getBot() will only return true if a bot was detected (speeds up detection a bit)
        discard_information: false

        # If true, bot detection will completely be skipped (bots will be detected as regular devices then)
        skip_detection: false

    twig:

        # If null, it will not assign Twig variable
        variable_name: 'device'

    routing:

        # If null, it will not tag DeviceDetector as routing condition service
        condition_service_alias: 'device'

Usage

Usage in controllers

You can inject DeviceDetector as a service. This bundle sets up an instance of this class according to the configurations under the acsiomatic_device_detector section in order to provide information about the main request.

use DeviceDetector\DeviceDetector;
use Symfony\Component\HttpFoundation\Response;

class MyController
{
    public function index(DeviceDetector $device): Response
    {
        if ($device->isSmartphone()) {
            // ...
        }
    }
}

Note

You need to call $device->parse() before asking for device's information if auto_parse configuration is false.

Usage in Twig

The DeviceDetector service is assigned to the Twig templates as device variable.

{% if device.isSmartphone %}
    {# ... #}
{% endif %}

Usage in route condition

The DeviceDetector is tagged as routing condition service.

use Symfony\Component\HttpFoundation\Response;

class MyController
{
    #[Route('/page', condition: "service('device').isSmartphone()")]
    public function index(): Response
    {
        // this endpoint is available only for smartphone devices
    }
}

Parsing custom request

You might want to parse other request than the current one. This bundle provides a service that implements DeviceDetectorFactoryInterface. This service provides methods that create fresh DeviceDetector instances according to the configurations under the acsiomatic_device_detector section, but it doesn't attach them to any request.

Custom parsers

You can inject custom parsers into DeviceDetector by providing them as services.

If autoconfigure is enabled, the bundle injects custom parsers. Otherwise, you need to add the corresponding tag to each custom parsers:

  • acsiomatic.device_detector.bot_parser
  • acsiomatic.device_detector.client_parser
  • acsiomatic.device_detector.device_parser

Release Policy

There is a single maintained branch per time. This branch targets a minor version.

A maintained version reaches its end-of-life when a new minor version is released.

Dependencies Compatibility Policy

This library is compatible with maintained versions of PHP, Device Detector, and Symfony.

acsiomatic/device-detector-bundle 适用场景与选型建议

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

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

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

围绕 acsiomatic/device-detector-bundle 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2020-11-28