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

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

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

michallkanak/symfony-cloudflare-multi-view

最新稳定版本:0.1.1

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

统计信息

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

GitHub 信息

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

其他信息

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

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固