michallkanak/symfony-cloudflare-multi-view 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

michallkanak/symfony-cloudflare-multi-view

Composer 安装命令:

composer require michallkanak/symfony-cloudflare-multi-view

包简介

Symfony Bundle for fetching, aggregating and presenting Cloudflare GraphQL analytics across multiple domains and accounts at once.

README 文档

README

Tests PHPStan Code Style Packagist Version Symfony Version PHP Version License

Symfony bundle for monitoring and visualizing traffic across multiple Cloudflare domains and accounts. It provides a beautiful, password-protected dashboard with real-time analytics, daily/hourly trends, and group-based organization.

Dashboard Preview

Dashboard View

Secure Login

Login Page

Features

  • Multi-domain aggregation: See stats for all your Cloudflare zones in one place.
  • Grouped view: Organize domains into logical Cloudflare accounts groups for better management.
  • Modern Dashboard: Sleek, glassmorphism UI with dark mode support.
  • Interactive Charts: Responsive charts for requests and unique visitors (powered by Chart.js).
  • Timezone Support: View data in your preferred local time.
  • Persistent State: Remembers your sorting and chart visibility preferences.
  • Geographical Analytics: Tracks Top 3 countries of origin for traffic with color-coded trend lines.
  • Security: Password-protected dashboard isolated from your main app. Implements CSRF protection and honeypot to prevent bot attacks.
  • Scalable: Built-in API rate limiting and retry logic for Cloudflare API.
  • Translations: Built-in support for multiple languages: English, Polish, French, German, Spanish, Italian, Czech, Swedish.

Installation

  1. Install via composer:

    composer require michallkanak/symfony-cloudflare-multi-view
  2. Register the bundle in config/bundles.php:

    return [
        // ...
        Michallkanak\SymfonyCloudflareMultiView\CfMultiViewBundle::class => ['all' => true],
    ];

Configuration

1. Main Configuration

Create config/packages/cf_multi_view.yaml:

cf_multi_view:
  dashboard_password: "%env(CF_DASHBOARD_PASSWORD)%"
  secure_dashboard: true # set to false to disable password protection
  timezone: "Europe/Warsaw"

  accounts:
    - name: "Main Account"
      token: "%env(CF_TOKEN_MAIN)%"
    - name: "Staging Account"
      token: "%env(CF_TOKEN_STAGING)%"

Each account.name becomes the group label on the dashboard. Domains are automatically assigned to their account group.

2. Routing

Create config/routes/cf_multi_view.yaml:

cf_multi_view:
  resource: "@CfMultiViewBundle/Resources/config/routes.yaml"
  prefix: "/cf-stats"

If you have admin panel in your symfony application, you can add this route to your admin panel routes.

Usage & Commands

1. Domain Discovery

Pull domains from all configured Cloudflare accounts:

php bin/console cf-multi-view:fetch-domains

# Or only for a specific account
php bin/console cf-multi-view:fetch-domains --account="Main Account"

This command populates the database and assigns each domain to its account group.

2. Synchronizing Statistics

# Sync all accounts, last 24h, with period depends on your subscription plan (Free: 1h)
php bin/console cf-multi-view:sync-stats --start="-24 hours" --period="1h"

# Sync with geographical data (Top 3 countries)
php bin/console cf-multi-view:sync-stats --with-countries

# Sync a specific account only
php bin/console cf-multi-view:sync-stats --account="Main Account" --with-countries

Options for sync-stats:

Option Description Default
--period Data granularity: 1m (Enterprise), 1h, 1d 1h
--start Start of the range -25 hours
--end End of the range now
--with-countries Fetch Top 3 country breakdown off
--account Sync only a specific account all

Recommended CRON:

*/5 * * * * php bin/console cf-multi-view:sync-stats --start="-2 hours" --with-countries > /dev/null 2>&1

3. Data Cleanup

Delete old statistics:

# Delete stats older than 90 days (asks for confirmation)
php bin/console cf-multi-view:purge-stats --older-than="90 days"

# Skip confirmation
php bin/console cf-multi-view:purge-stats --older-than="3 months" --force

Delete an entire account and all its data:

# Asks for confirmation
php bin/console cf-multi-view:delete-account --name="Staging Account"

# Skip confirmation
php bin/console cf-multi-view:delete-account --name="Staging Account" --force

Requirements

  • PHP 8.1+
  • Symfony 5.4+
  • Doctrine ORM
  • Cloudflare API Token with the following permissions:
    • Zone.Zone: Read
    • Zone.Analytics: Read

Translations

The bundle supports multiple languages out of the box for both the dashboard and CLI commands:

Language Code
English en
Polish pl
French fr
German de
Spanish es
Italian it
Czech cs
Swedish sv

Security

The dashboard is protected by a password defined in your configuration. By default, the bundle includes:

  • CSRF Protection: Form tokens to prevent cross-site request forgery.
  • Honeypot: Hidden fields to automatically reject bot attempts.

Advanced IP Protection (Optional)

If you require IP-level protection (e.g., blocking an IP address after 5 failed attempts), we recommend using the standard Symfony rate-limiter component in your main application and targeting the cf_multi_view_login route.

Contributing

Contributions are welcome! Please read the contributing guide CONTRIBUTING.md for details about our code of conduct, and the process for submitting pull requests to us.

Credits

Created by Michał Kanak

License

MIT

michallkanak/symfony-cloudflare-multi-view 适用场景与选型建议

michallkanak/symfony-cloudflare-multi-view 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2026 年 04 月 19 日, 在 PHP 生态内属于活跃度较高的组件。

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

围绕 michallkanak/symfony-cloudflare-multi-view 我们能提供哪些服务?
定制开发 / 二次开发

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

BUG 修复 & 性能优化

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

项目外包 & 长期维护

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

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

统计信息

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

GitHub 信息

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

其他信息

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