Download the PHP package tourze/wechat-official-account-server-message-bundle without Composer
On this page you can find all versions of the php package tourze/wechat-official-account-server-message-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download tourze/wechat-official-account-server-message-bundle
More information about tourze/wechat-official-account-server-message-bundle
Files in tourze/wechat-official-account-server-message-bundle
Package wechat-official-account-server-message-bundle
Short Description 微信公众号服务端消息处理组件
License MIT
Informations about the package wechat-official-account-server-message-bundle
WechatOfficialAccountServerMessageBundle
中文
A Symfony bundle for handling WeChat Official Account server messages and webhooks.
Features
- Message Processing: Handle incoming WeChat Official Account server messages
- Webhook Support: Process WeChat server callbacks with signature validation
- Message Persistence: Store server messages in database with automatic cleanup
- Event Dispatching: Dispatch events for custom message handling
- Async Processing: Support for asynchronous message handling via Symfony Messenger
- Lock Management: Prevent duplicate message processing
- User Synchronization: Automatically sync user information from WeChat
Installation
Requirements
- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM
Quick Start
Advanced Usage
Custom Message Processing
For more complex message handling scenarios:
Configuration
Bundle Registration
The bundle will be automatically registered if you use Symfony Flex. Otherwise, add it to your config/bundles.php:
Environment Variables
Configure message retention period:
Usage
Webhook Endpoint
The bundle provides a webhook endpoint at /wechat/official-account/server/{id} where {id} can be either:
- Account ID
- WeChat App ID
Message Types Supported
- Text messages
- Image messages
- Voice messages
- Video messages
- Location messages
- Link messages
- Event messages (subscribe, unsubscribe, click, etc.)
Event Handling
The bundle automatically handles all message types and dispatches events for custom processing. See the Quick Start section for basic usage.
Async Processing
Some message types are processed asynchronously via Symfony Messenger:
TEMPLATESENDJOBFINISHVIEWview_miniprogram
Database Schema
The bundle creates a wechat_official_account_message table to store server messages with the following fields:
id: Primary keyaccount_id: Reference to WeChat accountmsg_id: Unique message identifierto_user_name: Recipient OpenIDfrom_user_name: Sender OpenIDmsg_type: Message typecreate_time: Message timestampcontext: Full message context (JSON)
Automatic Cleanup
Server messages are automatically cleaned up using the Schedule Entity Clean Bundle. Messages older than the configured retention period are deleted daily at 5:26 AM.
Security
- Message signature validation for encrypted messages
- IP validation (TODO: implement WeChat IP whitelist check)
- Lock-based duplicate message prevention
Contributing
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests for new functionality
- Submit a pull request
License
This bundle is released under the MIT License. See the LICENSE file for details.
All versions of wechat-official-account-server-message-bundle with dependencies
doctrine/data-fixtures Version ^2.0
doctrine/dbal Version ^4.0
doctrine/doctrine-bundle Version ^2.13
doctrine/doctrine-fixtures-bundle Version ^4.0
doctrine/orm Version ^3.0
doctrine/persistence Version ^4.1
easycorp/easyadmin-bundle Version ^4
fakerphp/faker Version ^1.23
knplabs/knp-menu Version ^3.7
monolog/monolog Version ^3.1
psr/log Version ^3|^2|^1
symfony/config Version ^7.3
symfony/dependency-injection Version ^7.3
symfony/doctrine-bridge Version ^7.3
symfony/event-dispatcher-contracts Version ^3
symfony/framework-bundle Version ^7.3
symfony/http-foundation Version ^7.3
symfony/http-kernel Version ^7.3
symfony/lock Version ^7.3
symfony/messenger Version ^7.3
symfony/property-access Version ^7.3
symfony/routing Version ^7.3
symfony/yaml Version ^7.3
tourze/async-contracts Version 1.0.*
tourze/bundle-dependency Version 1.*
tourze/doctrine-upsert-bundle Version 1.0.*
tourze/easy-admin-attribute Version 0.1.*
tourze/easy-admin-menu-bundle Version 1.0.*
tourze/symfony-schedule-entity-clean-bundle Version 1.1.*
tourze/wechat-helper Version 0.0.*
tourze/wechat-official-account-bundle Version 0.1.*
tourze/wechat-official-account-contracts Version 0.0.*
tourze/wechat-official-account-oauth2-bundle Version 0.0.*
tourze/xml-helper Version 0.0.*