tourze / wechat-official-account-draft-bundle
微信公众号草稿管理包,提供草稿创建、存储和管理功能
Installs: 75
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 1
Forks: 0
Open Issues: 0
Type:symfony-bundle
pkg:composer/tourze/wechat-official-account-draft-bundle
Requires
- php: ^8.1
- doctrine/dbal: ^4.0
- doctrine/doctrine-bundle: ^2.13
- doctrine/orm: ^3.0
- doctrine/persistence: ^3.1 || ^4
- symfony/config: ^6.4
- symfony/dependency-injection: ^6.4
- symfony/event-dispatcher: ^6.4
- symfony/framework-bundle: ^6.4
- symfony/http-kernel: ^6.4
- symfony/yaml: ^6.4 || ^7.1
- tourze/doctrine-indexed-bundle: 0.0.*
- tourze/doctrine-ip-bundle: 0.0.*
- tourze/doctrine-snowflake-bundle: 0.1.*
- tourze/doctrine-timestamp-bundle: 0.0.*
- tourze/easy-admin-attribute: 0.1.*
- tourze/wechat-official-account-bundle: 0.1.*
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^10.0
This package is auto-updated.
Last update: 2025-11-03 06:27:21 UTC
README
A Symfony bundle for managing WeChat Official Account draft articles.
Table of Contents
- Features
- Dependencies
- Installation
- Configuration
- Quick Start
- Advanced Usage
- API Reference
- Security
- License
Features
- Draft entity management with Doctrine ORM
- Draft deletion functionality
- Support for WeChat Official Account API integration
- Built-in repository for draft operations
- Event-driven architecture with listeners
Dependencies
This bundle requires the following packages:
- PHP 8.1 or higher
- Symfony 6.4 or higher
- Doctrine ORM 3.0 or higher
- tourze/wechat-official-account-bundle
Installation
composer require tourze/wechat-official-account-draft-bundle
Configuration
The bundle integrates with the WeChat Official Account Bundle and requires proper configuration of the WeChat API credentials. Ensure you have configured the main WeChat bundle before using this draft extension.
Quick Start
1. Configure the bundle
Add the bundle to your config/bundles.php:
return [ // ... other bundles WechatOfficialAccountDraftBundle\WechatOfficialAccountDraftBundle::class => ['all' => true], ];
2. Create database tables
Run the Doctrine migrations to create the necessary tables:
php bin/console doctrine:migrations:migrate
3. Basic Usage
use WechatOfficialAccountDraftBundle\Entity\Draft; use WechatOfficialAccountDraftBundle\Request\DeleteDraftRequest; // Create a draft $draft = new Draft(); $draft->setAccount($account); $draft->setMediaId('media_id_from_wechat'); // Delete a draft $deleteRequest = new DeleteDraftRequest(); $deleteRequest->setAccount($account); $deleteRequest->setMediaId('media_id_to_delete');
Advanced Usage
Working with Draft Repository
use WechatOfficialAccountDraftBundle\Repository\DraftRepository; // Inject the repository public function __construct(private DraftRepository $draftRepository) { } // Find drafts by account $drafts = $this->draftRepository->findBy(['account' => $account]); // Find draft by media ID $draft = $this->draftRepository->findOneBy(['mediaId' => $mediaId]);
Event Handling
The bundle provides event-driven architecture for handling draft operations. You can listen to draft-related events to implement custom business logic.
API Reference
Entities
Draft: Main entity for managing draft articlesaccount: Associated WeChat accountmediaId: WeChat media ID for the draft
Requests
DeleteDraftRequest: Request handler for deleting drafts via WeChat API
Repository
DraftRepository: Repository for draft database operations
Security
This bundle follows security best practices:
- All input validation is handled through Symfony constraints
- Media ID length is limited to prevent database overflow
- Account associations use foreign key constraints with cascade deletion
If you discover any security vulnerabilities, please report them responsibly.
License
This bundle is released under the MIT License. See the LICENSE file for details.