PHPackages                             tourze/wechat-work-server-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. [HTTP &amp; Networking](/categories/http)
4. /
5. tourze/wechat-work-server-bundle

ActiveSymfony-bundle[HTTP &amp; Networking](/categories/http)

tourze/wechat-work-server-bundle
================================

企业微信服务端消息处理包，用于接收和处理企业微信回调消息

0.1.0(5mo ago)02681MITPHPCI failing

Since May 14Pushed 4mo ago1 watchersCompare

[ Source](https://github.com/tourze/wechat-work-server-bundle)[ Packagist](https://packagist.org/packages/tourze/wechat-work-server-bundle)[ RSS](/packages/tourze-wechat-work-server-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (3)Dependencies (44)Versions (4)Used By (1)

WechatWork Server Bundle
========================

[](#wechatwork-server-bundle)

[![PHP Version](https://camo.githubusercontent.com/acffb6ae1962992d26e4466782832787e79504a6250f80d732c4283458b9f497/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Symfony](https://camo.githubusercontent.com/5deb666a7576e7c1fcbc7eaef09cf087fbbd97fc11e66d274daa2486350a5ba7/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545362e342d626c75652e737667)](https://symfony.com/)[![Build Status](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)](#)[![Code Coverage](https://camo.githubusercontent.com/bd63309fd9fa3c09fac5db30229dd07c09b001230f0b7fb62ec98dc91b2f7208/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d39302532352d627269676874677265656e2e737667)](#)

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

A Symfony bundle for handling WeChat Work (企业微信) server-side messages and callback events.

Table of Contents
-----------------

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Configuration](#configuration)
    - [Bundle Registration](#bundle-registration)
    - [Route Configuration](#route-configuration)
- [Database Migration](#database-migration)
- [Quick Start](#quick-start)
    - [Handling Server Messages](#handling-server-messages)
- [Usage](#usage)
    - [Message Entity](#message-entity)
    - [Console Commands](#console-commands)
- [Advanced Usage](#advanced-usage)
    - [Custom Message Processing](#custom-message-processing)
    - [Message Filtering](#message-filtering)
- [Dependencies](#dependencies)
- [Contributing](#contributing)
    - [Development Setup](#development-setup)
- [License](#license)

Features
--------

[](#features)

- 🚀 **Server Message Processing**: Handle WeChat Work callback messages
- 🔒 **Message Encryption/Decryption**: Support for encrypted message processing
- 📊 **Message Storage**: Store and query server messages with Doctrine ORM
- 🎯 **Event System**: Dispatch events for message processing
- 📝 **Console Commands**: Import and manage server messages
- 🔄 **Callback Controllers**: Handle direct and server callbacks

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

[](#installation)

```
composer require tourze/wechat-work-server-bundle
```

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

[](#configuration)

### Bundle Registration

[](#bundle-registration)

Enable the bundle in your Symfony application:

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

### Route Configuration

[](#route-configuration)

Configure the routes for server callbacks:

```
# config/routes.yaml
wechat_work_server:
    resource: '@WechatWorkServerBundle/config/routes.yaml'
    prefix: /wechat-work/server
```

Database Migration
------------------

[](#database-migration)

Run the following command to create the necessary database tables:

```
php bin/console doctrine:migrations:migrate
```

Quick Start
-----------

[](#quick-start)

### Handling Server Messages

[](#handling-server-messages)

```
use WechatWorkServerBundle\Entity\ServerMessage;
use WechatWorkServerBundle\Event\WechatWorkServerMessageRequestEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class MessageHandler implements EventSubscriberInterface
{
    public static function getSubscribedEvents()
    {
        return [
            WechatWorkServerMessageRequestEvent::class => 'onServerMessage',
        ];
    }

    public function onServerMessage(WechatWorkServerMessageRequestEvent $event)
    {
        $message = $event->getMessage();

        // Process the message based on type
        switch ($message->getMsgType()) {
            case 'text':
                $this->handleTextMessage($message);
                break;
            case 'event':
                $this->handleEventMessage($message);
                break;
        }
    }
}
```

Usage
-----

[](#usage)

### Message Entity

[](#message-entity)

The `ServerMessage` entity stores WeChat Work server messages:

```
use WechatWorkServerBundle\Entity\ServerMessage;
use WechatWorkServerBundle\Repository\ServerMessageRepository;

// Get message repository
$repository = $entityManager->getRepository(ServerMessage::class);

// Create message from XML
$message = $repository->createFromXML($xmlContent);
if ($message) {
    $entityManager->persist($message);
    $entityManager->flush();
}

// Find messages by type
$textMessages = $repository->findBy(['msgType' => 'text']);

// Find messages by user
$userMessages = $repository->findBy(['fromUserName' => 'user123']);
```

### Console Commands

[](#console-commands)

The bundle provides console commands for managing server messages:

```
# Import server messages from log file
php bin/console wechat-work:import-server-message /path/to/message.log
```

**Command Details:**

- **wechat-work:import-server-message** - Import WeChat Work server messages from a log file

Advanced Usage
--------------

[](#advanced-usage)

### Custom Message Processing

[](#custom-message-processing)

```
use WechatWorkServerBundle\Controller\ServerCallbackController;
use Symfony\Component\HttpFoundation\Request;

// Custom callback handling
class CustomCallbackController extends ServerCallbackController
{
    protected function processMessage(array $messageData): void
    {
        // Custom processing logic
        parent::processMessage($messageData);
    }
}
```

### Message Filtering

[](#message-filtering)

```
use WechatWorkServerBundle\Repository\ServerMessageRepository;

class CustomMessageRepository extends ServerMessageRepository
{
    public function findRecentMessages(int $limit = 50): array
    {
        return $this->createQueryBuilder('m')
            ->orderBy('m.createTime', 'DESC')
            ->setMaxResults($limit)
            ->getQuery()
            ->getResult();
    }
}
```

Dependencies
------------

[](#dependencies)

- PHP 8.1+
- Symfony 6.4+
- Doctrine ORM 3.0+
- tourze/wechat-work-bundle
- tourze/wechat-helper
- tourze/xml-helper

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

[](#contributing)

We welcome contributions! Please follow these guidelines:

1. **Issues**: Please use GitHub Issues to report bugs or request features
2. **Pull Requests**:
    - Fork the repository
    - Create a feature branch
    - Make your changes with proper tests
    - Ensure PHPStan and PHPUnit tests pass
    - Submit a pull request

### Development Setup

[](#development-setup)

```
# Clone the repository
git clone https://github.com/your-org/php-monorepo.git
cd php-monorepo

# Install dependencies
composer install

# Run tests
./vendor/bin/phpunit packages/wechat-work-server-bundle/tests

# Run static analysis
php -d memory_limit=2G ./vendor/bin/phpstan analyse packages/wechat-work-server-bundle
```

License
-------

[](#license)

This project is licensed under the MIT License - see the [LICENSE](LICENSE) file for details.

###  Health Score

32

—

LowBetter than 71% of packages

Maintenance77

Regular maintenance activity

Popularity11

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity28

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

Every ~91 days

Total

3

Last Release

178d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/tourze)

---

Top Contributors

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[ec-cube/ec-cube

EC-CUBE EC open platform.

78527.0k1](/packages/ec-cube-ec-cube)[sylius/sylius

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

8.4k5.6M646](/packages/sylius-sylius)[contao/core-bundle

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)

PHPackages © 2026

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