tourze/wechat-mini-program-log-bundle
最新稳定版本:0.0.2
Composer 安装命令:
composer require tourze/wechat-mini-program-log-bundle
包简介
微信小程序日志管理Bundle,提供错误日志、反馈和处罚记录的同步和管理功能
README 文档
README
A Symfony bundle for managing WeChat Mini Program logs, including error tracking, feedback collection, and penalty management.
Table of Contents
- Features
- Installation
- Quick Start
- Configuration
- Dependencies
- Commands
- Entities
- Advanced Usage
- Security
- Automated Scheduling
- License
Features
- Error Tracking: Monitor and collect JavaScript errors from WeChat Mini Programs
- Feedback Management: Collect and manage user feedback from mini programs
- Penalty Monitoring: Track transaction experience score violations
- Automated Synchronization: Scheduled commands for data synchronization
- Entity Management: Doctrine entities for structured data storage
Installation
composer require tourze/wechat-mini-program-log-bundle
Quick Start
1. Register the Bundle
Add the bundle to your config/bundles.php:
return [ // ... WechatMiniProgramLogBundle\WechatMiniProgramLogBundle::class => ['all' => true], ];
2. Configure Services
The bundle automatically registers its services. Make sure you have the required dependencies installed.
3. Database Setup
Create and run migrations for the entity tables:
php bin/console make:migration php bin/console doctrine:migrations:migrate
Configuration
The bundle uses the WeChat Mini Program API client from
tourze/wechat-mini-program-bundle. Ensure your WeChat accounts are properly
configured with valid API credentials.
Example configuration in config/packages/wechat_mini_program.yaml:
wechat_mini_program: accounts: default: app_id: 'your_app_id' app_secret: 'your_app_secret'
Dependencies
This bundle requires the following packages:
- PHP 8.1 or higher
- Symfony 6.4 or higher
tourze/wechat-mini-program-bundle ^0.1- WeChat Mini Program API clienttourze/doctrine-timestamp-bundle ^0.0- Timestamp managementtourze/doctrine-snowflake-bundle ^0.1- Snowflake ID generationtourze/enum-extra ^0.1- Enhanced enum functionalitytourze/symfony-cron-job-bundle ^0.1- Automated task scheduling
Commands
The bundle provides four console commands for data synchronization:
Error Management
# Synchronize error list from WeChat API php bin/console wechat-mini-program:sync-get-error-list # Synchronize error details from WeChat API php bin/console wechat-mini-program:sync-get-error-detail
Feedback Collection
# Collect user feedback from mini programs
php bin/console wechat-mini-program:get-feedback
Penalty Monitoring
# Monitor transaction experience score violations
php bin/console wechat-mini-program:get-penalty
Entities
The bundle includes several entities for data management:
ErrorDetail: Detailed JavaScript error informationErrorListData: Aggregated error statisticsFeedback: User feedback dataPenaltyList: Transaction violation records
Advanced Usage
Custom Repository Usage
use WechatMiniProgramLogBundle\Repository\ErrorDetailRepository; class MyService { public function __construct( private ErrorDetailRepository $errorDetailRepository ) {} public function findRecentErrors(): array { return $this->errorDetailRepository->findBy( ['date' => new \DateTime('-7 days')], ['createTime' => 'DESC'], 10 ); } }
Event Listeners
Register custom event listeners to handle error data:
use Symfony\Component\EventDispatcher\EventSubscriberInterface; class ErrorEventSubscriber implements EventSubscriberInterface { public static function getSubscribedEvents(): array { return [ 'wechat.error.created' => 'onErrorCreated', ]; } public function onErrorCreated(ErrorEvent $event): void { // Custom error handling logic } }
Security
Data Validation
All entities include comprehensive validation constraints to ensure data integrity:
- String length limits prevent database overflow
- Type validation ensures proper data types
- Enum validation restricts values to valid choices
Access Control
The bundle does not include built-in access control. Implement appropriate security measures in your application:
- Use Symfony Security component for authentication
- Implement proper authorization checks
- Validate API credentials securely
Sensitive Data
Be aware that this bundle processes:
- User feedback data
- Error information that may contain sensitive details
- OpenID identifiers
Ensure compliance with relevant data protection regulations.
Automated Scheduling
All commands are configured with cron expressions for automated execution:
- Error list sync: Daily at 3:06 AM and 11:35 AM
- Error detail sync: Daily at 4:02 AM and 8:22 AM
- Feedback collection: Hourly at 15 minutes past
- Penalty monitoring: Daily at 1:40 AM and 1:45 PM
Contributing
We welcome contributions! Please see our contributing guidelines for details on:
- How to submit issues
- How to submit pull requests
- Code style requirements
- Testing requirements
License
This bundle is under the MIT license. See the complete license in the bundle:
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 0
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-10