PHPackages                             tourze/wechat-official-account-qrcode-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-official-account-qrcode-bundle

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

tourze/wechat-official-account-qrcode-bundle
============================================

微信公众号参数二维码功能包，支持二维码生成、扫描统计、跳转规则管理

0.0.1(11mo ago)00MITPHPPHP ^8.1CI passing

Since Jun 3Pushed 4mo ago1 watchersCompare

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

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

WechatOfficialAccountQrcodeBundle
=================================

[](#wechatofficialaccountqrcodebundle)

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

[![Latest Version](https://camo.githubusercontent.com/4d88251e429dffd7558dc5d8acdbaa632e8e3c2297ce8b0c18299c0fa1daae8c/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f746f75727a652f7765636861742d6f6666696369616c2d6163636f756e742d7172636f64652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-official-account-qrcode-bundle)[![PHP Version](https://camo.githubusercontent.com/63996c7d2d5f42bafd8fb408c6b380c179697acdacdc76f1c3445cd6129cfa48/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d253545382e312d626c75652e7376673f7374796c653d666c61742d737175617265)](https://php.net)[![License](https://camo.githubusercontent.com/6c711032aff1ca0eb6b211aa6cb3649ce7fd64a7714e1181d4bb457f9680e7cf/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![Total Downloads](https://camo.githubusercontent.com/0adc8ece7c87c2901a12786d93a578d47c63091284e26d710108aa5831cb54f4/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f746f75727a652f7765636861742d6f6666696369616c2d6163636f756e742d7172636f64652d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/tourze/wechat-official-account-qrcode-bundle)[![Code Coverage](https://camo.githubusercontent.com/d2cddccc52a6e3048d3a95213b3a1968f8aca3b2a4601993208d2ad5c5488b48/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d39302532352d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](#)

A Symfony bundle for WeChat Official Account QR code generation, management, and tracking.

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

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Dependencies](#dependencies)
- [Quick Start](#quick-start)
    - [1. Register the Bundle](#1-register-the-bundle)
    - [2. Create QR Code](#2-create-qr-code)
    - [3. Handle QR Code Scan Events](#3-handle-qr-code-scan-events)
- [Configuration](#configuration)
- [Entities](#entities)
    - [QrcodeTicket](#qrcodeticket)
    - [ScanLog](#scanlog)
    - [QrcodeJump](#qrcodejump)
- [QR Code Types](#qr-code-types)
- [API Examples](#api-examples)
    - [Create QR Code Request](#create-qr-code-request)
    - [Manage QR Code Jump Rules](#manage-qr-code-jump-rules)
- [Advanced Usage](#advanced-usage)
    - [Custom Event Handling](#custom-event-handling)
    - [Database Migrations](#database-migrations)
    - [Performance Optimization](#performance-optimization)
- [Events](#events)
- [Testing](#testing)
- [License](#license)

Features
--------

[](#features)

- Generate WeChat Official Account QR codes (temporary and permanent)
- Track QR code scan logs
- Manage QR code jump rules between WeChat Official Account and Mini Program
- Support for both scene ID and scene string parameters
- Real-time scan event handling

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

[](#installation)

```
composer require tourze/wechat-official-account-qrcode-bundle
```

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

[](#dependencies)

This bundle requires the following dependencies:

- **PHP**: ^8.1
- **Symfony**: ^6.4
- **Doctrine ORM**: ^3.0
- **tourze/wechat-official-account-bundle**: Core WeChat Official Account integration
- **tourze/doctrine-indexed-bundle**: Database indexing support
- **tourze/doctrine-timestamp-bundle**: Entity timestamp management
- **tourze/doctrine-snowflake-bundle**: Snowflake ID generation

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

[](#quick-start)

### 1. Register the Bundle

[](#1-register-the-bundle)

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

### 2. Create QR Code

[](#2-create-qr-code)

```
use WechatOfficialAccountQrcodeBundle\Entity\QrcodeTicket;
use WechatOfficialAccountQrcodeBundle\Enum\QrcodeActionName;

// Create a temporary QR code with scene ID
$qrcode = new QrcodeTicket();
$qrcode->setActionName(QrcodeActionName::QR_SCENE);
$qrcode->setSceneId(123);
$qrcode->setExpireTime(new \DateTimeImmutable('+1 hour'));

// Create a permanent QR code with scene string
$qrcode = new QrcodeTicket();
$qrcode->setActionName(QrcodeActionName::QR_LIMIT_STR_SCENE);
$qrcode->setSceneStr('user_invitation');
```

### 3. Handle QR Code Scan Events

[](#3-handle-qr-code-scan-events)

```
use WechatOfficialAccountQrcodeBundle\EventSubscriber\TicketMessageSubscriber;

// The bundle automatically handles scan events and creates scan logs
// You can subscribe to these events in your application
```

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

[](#configuration)

The bundle requires the following dependencies:

- `tourze/doctrine-indexed-bundle` - For database indexing
- `tourze/wechat-official-account-bundle` - For WeChat Official Account integration

Entities
--------

[](#entities)

### QrcodeTicket

[](#qrcodeticket)

- Main entity for QR code tickets
- Supports temporary and permanent QR codes
- Tracks expiration time, scene parameters, and ticket information

### ScanLog

[](#scanlog)

- Records QR code scan events
- Links to the QR code ticket and user information
- Immutable entity for audit trail

### QrcodeJump

[](#qrcodejump)

- Manages QR code jump rules
- Enables jumping from WeChat Official Account to Mini Program
- Supports rule publishing and editing

QR Code Types
-------------

[](#qr-code-types)

- `QR_SCENE` - Temporary QR code with integer scene ID
- `QR_STR_SCENE` - Temporary QR code with string scene parameter
- `QR_LIMIT_SCENE` - Permanent QR code with integer scene ID
- `QR_LIMIT_STR_SCENE` - Permanent QR code with string scene parameter

API Examples
------------

[](#api-examples)

### Create QR Code Request

[](#create-qr-code-request)

```
use WechatOfficialAccountQrcodeBundle\Request\CreateQrcodeRequest;

$request = new CreateQrcodeRequest();
$request->setActionName(QrcodeActionName::QR_SCENE);
$request->setSceneId(123);
$request->setExpireSeconds(3600);
```

### Manage QR Code Jump Rules

[](#manage-qr-code-jump-rules)

```
use WechatOfficialAccountQrcodeBundle\Request\QrcodeJumpAddRequest;

$request = new QrcodeJumpAddRequest();
$request->setPrefix('http://weixin.qq.com/q/xxx');
$request->setAppid('your_mini_program_appid');
$request->setPath('pages/index/index');
```

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

[](#advanced-usage)

### Custom Event Handling

[](#custom-event-handling)

You can create custom event subscribers to handle QR code scan events:

```
use Symfony\Component\EventDispatcher\EventSubscriberInterface;
use WechatOfficialAccountServerMessageBundle\Event\MessageEvent;

class CustomQrcodeEventSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            MessageEvent::class => 'handleScanEvent',
        ];
    }

    public function handleScanEvent(MessageEvent $event): void
    {
        $message = $event->getMessage();
        if ($message->getMsgType() === 'event' && $message->getEvent() === 'SCAN') {
            // Handle custom scan logic
            $sceneId = $message->getEventKey();
            // Your custom logic here
        }
    }
}
```

### Database Migrations

[](#database-migrations)

Create the required database tables:

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

### Performance Optimization

[](#performance-optimization)

For high-traffic applications, consider:

1. **Database Indexing**: The bundle automatically creates indexes for scan logs
2. **Caching**: Cache frequently accessed QR code data
3. **Async Processing**: Handle scan events asynchronously using Symfony Messenger

```
// config/packages/messenger.yaml
framework:
    messenger:
        transports:
            qrcode_scan: '%env(MESSENGER_TRANSPORT_DSN)%'
        routing:
            'WechatOfficialAccountQrcodeBundle\Message\*': qrcode_scan
```

Events
------

[](#events)

The bundle provides event subscribers for:

- QR code scan event handling
- Jump rule management
- Automatic scan log creation

Testing
-------

[](#testing)

Run the test suite:

```
./vendor/bin/phpunit packages/wechat-official-account-qrcode-bundle/tests
```

### Test Coverage

[](#test-coverage)

All 84 tests pass successfully with 258 assertions.

**Note**: Repository tests are currently implemented as unit tests instead of integration tests due to a known dependency resolution issue with `UserInterface` in the test environment. See [Issue #814](https://github.com/tourze/php-monorepo/issues/814) for tracking progress on this issue.

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

[](#contributing)

We welcome contributions! Please follow these guidelines:

1. **Report Issues**: Use the GitHub issue tracker to report bugs or request features
2. **Submit Pull Requests**: Fork the repository and submit pull requests with your changes
3. **Code Style**: Follow PSR-12 coding standards and existing code patterns
4. **Testing**: Ensure all tests pass and add tests for new functionality
5. **Documentation**: Update documentation for any new features or changes

### Development Setup

[](#development-setup)

1. Clone the repository
2. Install dependencies: `composer install`
3. Run tests: `./vendor/bin/phpunit packages/wechat-official-account-qrcode-bundle/tests`
4. Run static analysis: `./vendor/bin/phpstan analyse packages/wechat-official-account-qrcode-bundle`

Changelog
---------

[](#changelog)

### \[Unreleased\]

[](#unreleased)

- Initial release
- QR code generation and management
- Scan event tracking
- Jump rule management
- Comprehensive test coverage

License
-------

[](#license)

MIT License. See [LICENSE](LICENSE) for details.

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance64

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity35

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

344d 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 (4 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-wechat-official-account-qrcode-bundle/health.svg)

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M651](/packages/sylius-sylius)[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)[contao/core-bundle

Contao Open Source CMS

1231.6M2.4k](/packages/contao-core-bundle)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)[open-dxp/opendxp

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

7310.3k29](/packages/open-dxp-opendxp)

PHPackages © 2026

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