tourze/wechat-work-app-chat-bundle 问题修复 & 功能扩展

解决BUG、新增功能、兼容多环境部署,快速响应你的开发需求

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

tourze/wechat-work-app-chat-bundle

Composer 安装命令:

composer require tourze/wechat-work-app-chat-bundle

包简介

企业微信群聊管理服务组件

README 文档

README

PHP Version License Build Status Code Coverage

English | 中文

Enterprise WeChat group chat management bundle for Symfony applications.

Features

  • Create and manage Enterprise WeChat group chats
  • Send text, markdown, image, and file messages to group chats
  • Automatic message queue with retry mechanism
  • Symfony command-line tools for batch operations
  • Event-driven message sending

Requirements

  • PHP 8.1+
  • Symfony 6.4+
  • Enterprise WeChat Work API credentials

Installation

composer require tourze/wechat-work-app-chat-bundle

Configuration

Register the bundle in your application:

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

Usage

Services

AppChatService

Manages Enterprise WeChat group chats:

use WechatWorkAppChatBundle\Service\AppChatService;

// Create a new group chat
$appChatService->createAppChat($chatId, $name, $owner, $userList);

// Update group chat information
$appChatService->updateAppChat($appChat);

// Sync group chat information from WeChat Work API
$appChatService->syncAppChat($appChat);

// Sync all unsynced group chats
$appChatService->syncUnsynced();

MessageService

Handles message sending to group chats:

use WechatWorkAppChatBundle\Service\MessageService;

// Send text message
$messageService->sendText($chatId, $content, $mentionedList = [], $mentionedMobileList = []);

// Send markdown message
$messageService->sendMarkdown($chatId, $content);

// Send image message
$messageService->sendImage($chatId, $mediaId);

// Send file message
$messageService->sendFile($chatId, $mediaId);

// Send all unsent messages
$messageService->sendUnsent();

Entities

  • AppChat: Represents an Enterprise WeChat group chat
  • TextMessage: Plain text messages with @mention support
  • MarkdownMessage: Markdown formatted messages
  • ImageMessage: Image messages with media ID
  • FileMessage: File messages with media ID

Commands

Send Unsent Messages

Sends all queued messages that haven't been sent yet:

bin/console wechat-work:app-chat:send-unsent

This command:

  • Retrieves all unsent messages from the database
  • Attempts to send each message via WeChat Work API
  • Updates message status upon successful sending
  • Handles errors gracefully with detailed output

Sync Group Chats

Synchronizes group chat information with WeChat Work API:

bin/console wechat-work:app-chat:sync

This command:

  • Fetches all unsynced group chats
  • Retrieves latest information from WeChat Work API
  • Updates local database with current group chat details
  • Reports sync status and any errors

Event Subscribers

The bundle includes an automatic message sending subscriber that triggers when new messages are persisted to the database. This ensures messages are sent immediately when created.

Examples

Creating and Sending Messages

// Create a text message
$textMessage = new TextMessage();
$textMessage->setChatId('your-chat-id');
$textMessage->setContent('Hello, World!');
$textMessage->setMentionedList(['@all']); // Mention everyone

// Save to database (automatically triggers sending)
$entityManager->persist($textMessage);
$entityManager->flush();

// Send markdown message directly
$messageService->sendMarkdown('your-chat-id', '# Important Notice\n\nPlease check the latest updates.');

Managing Group Chats

// Create a new group chat
$appChat = new AppChat();
$appChat->setChatId('tech-team-001');
$appChat->setName('Tech Team Discussion');
$appChat->setOwner('john.doe');
$appChat->setUserList(['john.doe', 'jane.smith', 'bob.wilson']);

$entityManager->persist($appChat);
$entityManager->flush();

// Sync with WeChat Work API
$appChatService->syncAppChat($appChat);

Testing

Run the test suite:

./vendor/bin/phpunit packages/wechat-work-app-chat-bundle/tests

Contributing

Please read the main repository's contributing guidelines before submitting pull requests.

License

This bundle is licensed under the same license as the parent monorepo.

tourze/wechat-work-app-chat-bundle 适用场景与选型建议

tourze/wechat-work-app-chat-bundle 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 0, 最近一次更新时间为 2025 年 06 月 03 日, 在 PHP 生态内属于活跃度较高的组件。

我们在过去多个企业项目中使用过 tourze/wechat-work-app-chat-bundle 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。

围绕 tourze/wechat-work-app-chat-bundle 我们能提供哪些服务?
定制开发 / 二次开发

基于 tourze/wechat-work-app-chat-bundle 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。

BUG 修复 & 性能优化

线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。

项目外包 & 长期维护

承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。

yvsm@zunyunkeji.com QQ:316430983 微信:yvsm316 西安尊云信息科技 · 专注 PHP / Go / 分布式系统研发

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2025-06-03