PHPackages                             tourze/wechat-work-app-chat-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/wechat-work-app-chat-bundle

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

tourze/wechat-work-app-chat-bundle
==================================

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

0.0.1(1y ago)00MITPHPPHP ^8.1CI passing

Since Jun 3Pushed 6mo ago1 watchersCompare

[ Source](https://github.com/tourze/wechat-work-app-chat-bundle)[ Packagist](https://packagist.org/packages/tourze/wechat-work-app-chat-bundle)[ RSS](/packages/tourze-wechat-work-app-chat-bundle/feed)WikiDiscussions master Synced today

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

Wechat Work App Chat Bundle
===========================

[](#wechat-work-app-chat-bundle)

[![PHP Version](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](https://www.php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/07c5a0015c097e0dfbb44d4220df0eed6a623d83eceb02ac299fe96b8e4e1a73/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f7068702d6d6f6e6f7265706f2f63692e796d6c3f6272616e63683d6d6173746572)](https://github.com/tourze/php-monorepo/actions)[![Code Coverage](https://camo.githubusercontent.com/9cb168340a6d5a1bdda8e16dafe8eed3d60f1441986fb63de17bff84ee6a18f0/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f)](https://codecov.io/gh/tourze/php-monorepo)

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

Enterprise WeChat group chat management bundle for Symfony applications.

Features
--------

[](#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
------------

[](#requirements)

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

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

[](#installation)

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

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

[](#configuration)

Register the bundle in your application:

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

Usage
-----

[](#usage)

### Services

[](#services)

#### AppChatService

[](#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

[](#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

[](#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

[](#commands)

#### Send Unsent Messages

[](#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

[](#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

[](#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
--------

[](#examples)

### Creating and Sending Messages

[](#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

[](#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
-------

[](#testing)

Run the test suite:

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

Contributing
------------

[](#contributing)

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

License
-------

[](#license)

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

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance58

Moderate activity, may be stable

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity36

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

396d ago

### Community

Maintainers

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

---

Top Contributors

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

---

Tags

wechat

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-wechat-work-app-chat-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-wechat-work-app-chat-bundle/health.svg)](https://phpackages.com/packages/tourze-wechat-work-app-chat-bundle)
```

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.9M388](/packages/easycorp-easyadmin-bundle)[sylius/sylius

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

8.5k5.9M738](/packages/sylius-sylius)[open-dxp/opendxp

Content &amp; Product Management Framework (CMS/PIM)

9421.6k61](/packages/open-dxp-opendxp)[oro/platform

Business Application Platform (BAP)

645143.5k115](/packages/oro-platform)[contao/core-bundle

Contao Open Source CMS

1231.6M2.8k](/packages/contao-core-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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