承接 the-3labs-team/php-cloudflare-analytics 相关项目开发

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

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

the-3labs-team/php-cloudflare-analytics

Composer 安装命令:

composer require the-3labs-team/php-cloudflare-analytics

包简介

A php package to retrieve page views and other data from Cloudflare Analytics

README 文档

README

This package is a simple PHP client for the Cloudflare Analytics GraphQL API.

⚠️ Note: This package is not official and is not affiliated with Cloudflare. It is a community-driven package.

🚨 Note 2: This package is under development and is not ready for production.

Installation

You can install the package via composer:

composer require the-3labs-team/php-cloudflare-analytics

Configuration

Add in your .env file the following variables:

CLOUDFLARE_API_TOKEN='your_cloudflare_api_token'
CLOUDFLARE_ZONE_TAG_ID='zoneTag'

or you can pass the token and zoneTag as parameters in the constructor.

use The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics;

$cf = new CloudflareAnalytics(
    token: 'your_cloudflare_api_token', zoneTag: 'zoneTag'
);

Usage

You can use the following methods to build your query:

use The3LabsTeam\PhpCloudflareAnalytics\CloudflareAnalytics;

$cf = new CloudflareAnalytics;

$results = $cf->select('firewallEventsAdaptive AS firewall')
    ->get('firewall.datetime', 'firewall.action');

The get method will return an array with the results.

Available fields

  • firewallEventsAdaptive
  • httpRequests1mGroups
  • httpRequestsAdaptiveGroups
  • threatsAdaptiveGroups
  • threatsByCountryAdaptiveGroups

Default fields

  • datetime: 1 hour
  • take: 10
  • orderBy: datetime

Demo

Get latest 10 firewall events:

$results = $cf->select('firewallEventsAdaptive AS firewall')
    ->get('firewall.datetime', 'firewall.action');

Filter between two dates:

$results = $cf->select('firewallEventsAdaptive AS firewall')
    ->where('firewall.datetime', '>=', '2021-10-01T00:00:00Z')
    ->where('firewall.datetime', '<=', '2021-10-02T00:00:00Z')
    ->get('firewall.datetime', 'firewall.action');

Limit the results:

$results = $cf->select('firewallEventsAdaptive AS firewall')
    ->take('firewall', 5)
    ->get('firewall.datetime', 'firewall.action');

Order the results:

$results = $cf->select('firewallEventsAdaptive AS firewall')
    ->orderBy('firewall.datetime', 'desc')
    ->get('firewall.datetime', 'firewall.action');

Get two fields from two different tables: // TODO: test this

$results = $cf->select('firewallEventsAdaptive AS firewall, threatsAdaptiveGroups AS threats')
    ->get('firewall.datetime', 'firewall.action', 'threats.datetime', 'threats.action');

Get http visits and sum them:

    $results = $cf->select('httpRequests1mGroups AS http')
        ->take('http', 10)
        ->get('sum.countryMap.clientCountryName', 'sum.countryMap.requests', 'sum.countryMap.bytes', 'sum.countryMap.threats', 'dimensions.datetimeHour');

Testing

composer test

License

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

Credits

// TODO: Add the rest of the file

Sponsor

Tom's Hardware - Notizie, recensioni, guide all'acquisto e approfondimenti per tutti gli appassionati di computer, smartphone, videogiochi, film, serie tv, gadget e non solo Spaziogames - Tutto sul mondo dei videogiochi. Troverai tantissime anteprime, recensioni, notizie dei giochi per tutte le console, PC, iPhone e Android.
Cpop - News, recensioni, guide su fumetto, cinema & serie TV, gioco da tavolo e di ruolo e collezionismo. Tutto quello di cui hai bisogno per rimanere aggiornato sul mondo della cultura pop Data4Biz - Sito dedicato alla trasformazione digitale del business
SOS Home & Garden - Realtà dedicata a 360 gradi ai settori della casa e del giardino. Techradar - Le ultime notizie e recensioni dal mondo della tecnologia, su computer, sistemi per la casa, gadget e altro.
Aibay - Scopri AiBay, il leader delle notizie sull'intelligenza artificiale. Resta aggiornato sulle ultime innovazioni, ricerche e tendenze del mondo AI con approfondimenti, interviste esclusive e analisi dettagliate. Coinlabs - Notizie, analisi approfondite, guide e opinioni aggiornate sul mondo delle criptovalute, blockchain e finanza

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2024-08-05