PHPackages                             tourze/baidu-tongji-api-bundle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. tourze/baidu-tongji-api-bundle

ActiveSymfony-bundle[API Development](/categories/api)

tourze/baidu-tongji-api-bundle
==============================

0.0.1(6mo ago)00MITPHPCI failing

Since Nov 13Pushed 4mo agoCompare

[ Source](https://github.com/tourze/baidu-tongji-api-bundle)[ Packagist](https://packagist.org/packages/tourze/baidu-tongji-api-bundle)[ RSS](/packages/tourze-baidu-tongji-api-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (36)Versions (2)Used By (0)

Baidu Tongji API Bundle
=======================

[](#baidu-tongji-api-bundle)

[English](README.md) | [中文](README.zh-CN.md)

A Symfony bundle for integrating Baidu Tongji (Baidu Analytics) API into your application. This bundle provides comprehensive functionality to manage Baidu Tongji sites, retrieve analytics reports, and synchronize data with local storage.

Features
--------

[](#features)

- **Site Management**: Sync and manage Baidu Tongji sites and subdirectories
- **Report Retrieval**: Access various types of analytics reports (trends, sources, visits, etc.)
- **Data Storage**: Store report data locally using Doctrine ORM entities
- **CLI Commands**: Convenient console commands for data synchronization
- **Admin Interface**: EasyAdmin integration for managing data
- **OAuth2 Integration**: Seamless integration with Baidu OAuth2 authentication

Requirements
------------

[](#requirements)

- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM
- `tourze/baidu-oauth2-integrate-bundle` - For Baidu OAuth2 authentication

Installation
------------

[](#installation)

Install the bundle using Composer:

```
composer require tourze/baidu-tongji-api-bundle
```

Configuration
-------------

[](#configuration)

Enable the bundle in your Symfony application:

```
// config/bundles.php
return [
    // ...
    Tourze\BaiduTongjiApiBundle\BaiduTongjiApiBundle::class => ['all' => true],
];
```

Console Commands
----------------

[](#console-commands)

### tongji:sync-sites

[](#tongjisync-sites)

Synchronize Baidu Tongji sites for users.

#### Basic Usage

[](#basic-usage)

```
# Sync sites for all users
php bin/console tongji:sync-sites

# Sync sites for specific user
php bin/console tongji:sync-sites --user-id=123

# Force sync, ignore token expiration
php bin/console tongji:sync-sites --force
```

#### Options

[](#options)

- `--user-id, -u`: Specific user ID to sync (syncs all users if not specified)
- `--force, -f`: Force sync, ignore token expiration check

#### Examples

[](#examples)

```
# Sync all user sites
php bin/console tongji:sync-sites

# Sync specific user sites
php bin/console tongji:sync-sites -u 12345

# Force sync sites and update tokens
php bin/console tongji:sync-sites --force
```

### tongji:sync-report

[](#tongjisync-report)

Synchronize Baidu Tongji analytics reports.

#### Basic Usage

[](#basic-usage-1)

```
# Sync trend report for all sites
php bin/console tongji:sync-report trend/time/a --start-date=2024-01-01 --end-date=2024-01-31

# Sync report for specific site
php bin/console tongji:sync-report trend/time/a --site-id=123456 --start-date=2024-01-01 --end-date=2024-01-31

# Force sync, ignore token expiration
php bin/console tongji:sync-report trend/time/a --start-date=2024-01-01 --end-date=2024-01-31 --force
```

#### Parameters

[](#parameters)

**Required Parameters:**

- `method`: Report method to retrieve (see table below)

**Optional Parameters:**

- `--site-id, -s`: Specific site ID to sync (syncs all sites if not specified)
- `--start-date`: Start date in YYYY-MM-DD format
- `--end-date`: End date in YYYY-MM-DD format
- `--params, -p`: Additional parameters in JSON format, default: `{}`
- `--force, -f`: Force sync, ignore token expiration check

#### Available Report Methods

[](#available-report-methods)

MethodDescription`trend/time/a`Trend Analysis`trend/latest/a`Real-time Visitors`pro/product/a`Promotion Methods`pro/hour/a`Baidu Promotion Trend`source/all/a`All Sources`source/engine/a`Search Engines`source/searchword/a`Search Words`source/link/a`External Links`custom/media/a`Custom Media Tracking`visit/toppage/a`Top Pages`visit/landingpage/a`Landing Pages`visit/topdomain/a`Top Domains`visit/district/a`Regional Distribution (China)`visit/world/a`World Regional Distribution`overview/getTimeTrendRpt`Site Overview (Trend Data)`overview/getDistrictRpt`Site Overview (Regional Distribution)`overview/getCommonTrackRpt`Site Overview (Common Tracks)#### Examples

[](#examples-1)

```
# Sync trend report for all sites
php bin/console tongji:sync-report trend/time/a --start-date=2024-01-01 --end-date=2024-01-31

# Sync search engine report for specific site
php bin/console tongji:sync-report source/engine/a -s 123456 --start-date=2024-01-01 --end-date=2024-01-31

# Sync report with custom parameters
php bin/console tongji:sync-report trend/time/a --start-date=2024-01-01 --end-date=2024-01-31 -p '{"gran":"day"}'

# Force sync report and update tokens
php bin/console tongji:sync-report trend/time/a --start-date=2024-01-01 --end-date=2024-01-31 --force
```

Entities
--------

[](#entities)

### TongjiSite

[](#tongjisite)

Represents a Baidu Tongji site with the following properties:

- `siteId`: Baidu site ID
- `domain`: Site domain
- `status`: Site status (0: normal, 1: paused)
- `user`: Associated Baidu OAuth2 user
- `subDirectories`: Collection of subdirectories
- `siteCreateTime`: Site creation time
- `rawData`: Raw API response data

### TongjiSubDirectory

[](#tongjisubdirectory)

Represents a Baidu Tongji subdirectory with the following properties:

- `subDirId`: Subdirectory ID
- `subDir`: Subdirectory path
- `status`: Subdirectory status
- `site`: Associated site

### FactTrafficTrend

[](#facttraffictrend)

Stores aggregated traffic trend data:

- `siteId`: Site ID
- `date`: Report date
- `pageViewPv`: Page views count
- `visitorUv`: Unique visitors count
- `ipCount`: IP count
- `bounceRatio`: Bounce rate
- `avgVisitTime`: Average visit time

### RawTongjiReport

[](#rawtongjireport)

Stores raw report data from Baidu Tongji API:

- `reportMethod`: Report method name
- `siteId`: Site ID
- `reportDate`: Report date
- `rawData`: Raw JSON data from API

Services
--------

[](#services)

### TongjiApiClient

[](#tongjiapiclient)

Core API client for communicating with Baidu Tongji API endpoints.

### TongjiSiteService

[](#tongjisiteservice)

Manages site synchronization and site-related operations.

### TongjiReportSyncService

[](#tongjireportsyncservice)

Handles report data synchronization and processing.

### UserManagementService

[](#usermanagementservice)

Manages user-related operations and authentication.

Testing
-------

[](#testing)

Run the test suite:

```
vendor/bin/phpunit packages/baidu-tongji-api-bundle/tests/
```

Run static analysis:

```
vendor/bin/phpstan analyse packages/baidu-tongji-api-bundle/src/ --level=8
```

License
-------

[](#license)

MIT License

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance72

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

180d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

[![tourze](https://avatars.githubusercontent.com/u/13899502?v=4)](https://github.com/tourze "tourze (1 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-baidu-tongji-api-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-baidu-tongji-api-bundle/health.svg)](https://phpackages.com/packages/tourze-baidu-tongji-api-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
