定制 3brs/sylius-analytics-plugin 二次开发

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

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

3brs/sylius-analytics-plugin

Composer 安装命令:

composer require 3brs/sylius-analytics-plugin

包简介

Analytics tracking plugin for Sylius front store and product views.

README 文档

README

Sylius Analytics Plugin

Features

  • Asynchronously logs visits to all frontend pages (excluding admin)
  • Tracks visitor data: channel, full URL, route name, customer, session ID, IP address, user agent, and timestamp
  • Displays:
    • Most requested pages in the last X days (configurable)
    • Request counts on product detail pages
    • Full log of requests with filtering capabilities inside the admin panel
  • Built on top of Symfony Messenger for asynchronous processing

Installation

  1. Run composer require 3brs/sylius-analytics-plugin.

  2. Register plugin in your config/bundles.php

    ThreeBRS\SyliusAnalyticsPlugin\ThreeBRSSyliusAnalyticsPlugin::class => ['all' => true],
  3. Import configuration to config/packages/threebrs_sylius_analytics_plugin.yaml:

    imports:
        - { resource: "@ThreeBRSSyliusAnalyticsPlugin/config/config.yaml" }
  4. Import routing to config/routes.yaml:

    threebrs_statistics_plugin_routing_file:
        resource: "@ThreeBRSSyliusAnalyticsPlugin/config/routes.yaml"
        prefix: '%sylius_admin.path_name%'
  5. Messenger Transport Configuration

    This plugin uses Symfony Messenger to log requests.

    Default Behavior (Synchronous)

    • By default, the plugin uses synchronous processing via the sync:// DSN. This means that log messages are processed immediately, without requiring any queue or worker. This is ideal for development and testing environments.

    • To enable this mode, set the following in your .env:

    THREEBRS_MESSENGER_TRANSPORT_LOG_VISIT_DSN=sync://
    • For better performance in production or staging environments, you can configure the plugin to log requests asynchronously using a queue (e.g., Doctrine transport)
    THREEBRS_MESSENGER_TRANSPORT_LOG_VISIT_DSN=doctrine://default
    • After setting this, you must run the Messenger worker to process the queued log messages:
    bin/console messenger:consume log_visit -vv
    • Only use this mode if your project supports background workers and a transport like Doctrine, Redis, etc.
  6. Configure how many past days are considered when calculating the "Most Visited Pages" in the admin dashboard by setting the following parameter:

    parameters:
        threebrs_analytics_plugin.request_log_days: 7 # Change as needed
  7. Generate and run Doctrine migrations:

    bin/console doctrine:migrations:diff 
    bin/console doctrine:migrations:migrate
  8. Optional: Enable UTF-8 support in routing for better slug handling (diacritics, etc.):

    # config/packages/routing.yaml
    framework:
        router:
            utf8: true

Usage

The plugin will automatically log requests on:

  • Homepage
  • Product detail pages
  • Category pages
  • Cart pages
  • Other shop pages

You can view the statistics inside the admin panel under the Analytics section.
Log processing is handled via Symfony Messenger, either synchronously (by default) or asynchronously if a queue is configured.

Development

Setup

Initialize the development environment:

make init

This command installs dependencies, sets up the database, and prepares frontend assets (or follow related steps in Makefile).

Usage

  • Develop your plugin logic inside /src
  • See bin/ for useful dev tools

Testing

Run all tests and quality checks:

make ci

Run individual checks:

make phpstan    # Static analysis
make ecs        # Code style check
make fix        # Fix code style issues
make lint       # Symfony and Doctrine linting
make behat      # Behavioral tests

Database Management

make fixtures       # Load test fixtures

Development Server

Start the development environment:

make run           # Start Docker containers
make bash          # Access PHP container shell

Other Useful Commands

make static        # Run static analysis (PHPStan + ECS + Lint)
make cache         # Clear application cache
make var           # Recreate var directory

All commands use the test environment by default. See the Makefile for detailed implementation of each target.

License

This library is under the MIT license.

Credits

Developed by 3BRS

3brs/sylius-analytics-plugin 适用场景与选型建议

3brs/sylius-analytics-plugin 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 62 次下载、GitHub Stars 达 2, 最近一次更新时间为 2025 年 07 月 15 日, 在 PHP 生态内属于活跃度较高的组件。

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

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

围绕 3brs/sylius-analytics-plugin 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

  • Stars: 2
  • Watchers: 3
  • Forks: 0
  • 开发语言: PHP

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-07-15