PHPackages                             tourze/wechat-mini-program-url-link-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. tourze/wechat-mini-program-url-link-bundle

ActiveSymfony-bundle

tourze/wechat-mini-program-url-link-bundle
==========================================

微信小程序 URL Link

0.1.1(5mo ago)00MITPHPPHP ^8.2CI failing

Since Jun 3Pushed 4mo ago1 watchersCompare

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

READMEChangelog (3)Dependencies (61)Versions (4)Used By (0)

wechat-mini-program-url-link-bundle
===================================

[](#wechat-mini-program-url-link-bundle)

[![PHP Version](https://camo.githubusercontent.com/acffb6ae1962992d26e4466782832787e79504a6250f80d732c4283458b9f497/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c75652e737667)](https://php.net/)[![License](https://camo.githubusercontent.com/8bb50fd2278f18fc326bf71f6e88ca8f884f72f179d3e555e20ed30157190d0d/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d677265656e2e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo)[![Code Coverage](https://camo.githubusercontent.com/06e33fb4024f7f9c576cc80d22e78dbb33bd31fd8dbf978c6effb2adbf0f5087/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d39352532352d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo)

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

WeChat Mini Program URL Link management bundle, providing URL Link (short link) and promotion code generation, management, and statistics features.

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

[](#table-of-contents)

- [Features](#features)
- [Installation](#installation)
- [Quick Start](#quick-start)
- [Main Features](#main-features)
- [Configuration](#configuration)
- [Advanced Usage](#advanced-usage)
- [Testing](#testing)
- [Dependencies](#dependencies)
- [License](#license)

Features
--------

[](#features)

- Generate WeChat Mini Program URL Links (short links)
- Promotion code generation and management
- Visit statistics and analysis
- Automatic URL Link visit status query
- Daily promotion effectiveness statistics

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

[](#installation)

```
composer require tourze/wechat-mini-program-url-link-bundle
```

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

[](#quick-start)

### 1. Register the Bundle

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

In your `config/bundles.php`:

```
return [
    // ... other bundles
    WechatMiniProgramUrlLinkBundle\WechatMiniProgramUrlLinkBundle::class => ['all' => true],
];
```

### 2. Update Database Schema

[](#2-update-database-schema)

```
php bin/console doctrine:schema:update --force
```

### 3. Basic Usage

[](#3-basic-usage)

```
// Generate a promotion code
$promotionCode = new PromotionCode();
$promotionCode->setName('New Year Promotion');
$promotionCode->setCode('NY2024');
$promotionCode->setLinkUrl('pages/promotion/detail');
$promotionCode->setAccount($miniProgramAccount);

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

// Access the short link
// Visit: https://yourdomain.com/t.htm?NY2024
```

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

[](#configuration)

This bundle uses standard Symfony Bundle configuration, with main configuration items injected through the service container.

### Required Service Dependencies

[](#required-service-dependencies)

- `WechatMiniProgramBundle\Service\Client` - WeChat Mini Program client service
- `EntityManagerInterface` - Doctrine entity manager
- `LoggerInterface` - Logger service

### Environment Variables

[](#environment-variables)

```
# Redirect page path (optional, default: pages/redirect/index)
WECHAT_MINI_PROGRAM_PROMOTION_REDIRECT_PATH=pages/redirect/index
```

Main Features
-------------

[](#main-features)

### 1. URL Link Management

[](#1-url-link-management)

URL Link is a short link feature provided by WeChat Mini Program that allows opening mini programs from outside WeChat.

#### Entity Description

[](#entity-description)

- `UrlLink` - URL Link entity, stores generated short link information
- `VisitLog` - Visit log, records user visit history
- `DailyStatus` - Daily statistics data

#### Core Services

[](#core-services)

- `UrlLinkService` - URL Link core service, provides short link query and status update functionality

### 2. Promotion Code Feature

[](#2-promotion-code-feature)

The promotion code system is used to track promotion effectiveness across different channels.

#### Entity Description

[](#entity-description-1)

- `PromotionCode` - Promotion code entity
- `CodeRule` - Promotion code rule configuration
- `CodeRuleTag` - Promotion code tags

### 3. API Endpoints

[](#3-api-endpoints)

#### Generate Short Link

[](#generate-short-link)

- **Route**: `POST /api/wechat-mini-program/url-link/generate`
- **Request Parameters**: `GenerateUrlLinkRequest`
- **Function**: Generate new mini program short link

#### Query Short Link

[](#query-short-link)

- **Route**: `POST /api/wechat-mini-program/url-link/query`
- **Request Parameters**: `QueryUrlLinkRequest`
- **Function**: Query short link visit status

### 4. Console Commands

[](#4-console-commands)

#### wechat-mini-program:count-promotion-daily-status

[](#wechat-mini-programcount-promotion-daily-status)

Periodically count promotion code visit numbers.

**Purpose**:

- Count daily visits for each promotion code
- Update daily statistics data
- Supports scheduled task execution (every 10 minutes)

**Usage**:

```
bin/console wechat-mini-program:count-promotion-daily-status
```

**Features**:

- Automatically count all promotion code visits for the current day
- Update or create `DailyStatus` records
- Only update data when visit count increases

#### wechat-mini-program:query-url-link-result

[](#wechat-mini-programquery-url-link-result)

Batch query URL Link click results.

**Purpose**:

- Batch check unconfirmed short link statuses
- Get visitor information through WeChat API
- Automatically mark expired links

**Usage**:

```
# Default: process 500 records, 60 minutes timeout
bin/console wechat-mini-program:query-url-link-result

# Custom record count and timeout
bin/console wechat-mini-program:query-url-link-result 1000 120
```

**Parameters**:

- `limit` (optional): Number of records to process at once, default 500
- `minute` (optional): Timeout in minutes, default 60

**Features**:

- Query all URL Links with `checked = false`
- Call WeChat API to get visitor's OpenID
- Automatically mark links as checked if not visited within specified time
- Supports scheduled task execution (every 10 minutes)

### 5. Event System

[](#5-event-system)

#### PromotionCodeRequestEvent

[](#promotioncoderequestevent)

Promotion code request event, triggered when processing promotion code related requests.

Database Tables
---------------

[](#database-tables)

Includes the following main tables:

- `wechat_mini_program_url_link` - URL Link table
- `wechat_mini_program_promotion_code` - Promotion code table
- `wechat_mini_program_code_rule` - Promotion code rule table
- `wechat_mini_program_code_rule_tag` - Promotion code tag table
- `wechat_mini_program_visit_log` - Visit log table
- `wechat_mini_program_daily_status` - Daily statistics table

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

[](#advanced-usage)

### Generate URL Link

[](#generate-url-link)

```
use WechatMiniProgramUrlLinkBundle\Request\GenerateUrlLinkRequest;

$request = new GenerateUrlLinkRequest();
$request->setPath('/pages/index/index');
$request->setQuery('source=test');
$request->setIsExpire(true);
$request->setExpireType(1);
$request->setExpireInterval(7);

// Call through API endpoint
// POST /api/wechat-mini-program/url-link/generate
```

### Query URL Link Status

[](#query-url-link-status)

```
use WechatMiniProgramUrlLinkBundle\Service\UrlLinkService;

// Inject service
$urlLinkService = $container->get(UrlLinkService::class);

// Query specific URL Link status
$urlLink = $urlLinkRepository->find($id);
$urlLinkService->apiCheck($urlLink);
```

### Generate QR Code for Promotion Code

[](#generate-qr-code-for-promotion-code)

```
use WechatMiniProgramUrlLinkBundle\Service\PromotionCodeQrcodeService;

// Inject service
$qrcodeService = $container->get(PromotionCodeQrcodeService::class);

// Generate QR code for promotion code
$imageUrl = $qrcodeService->generateQrcode($promotionCode);
```

Testing
-------

[](#testing)

Run unit tests:

```
./vendor/bin/phpunit packages/wechat-mini-program-url-link-bundle/tests
```

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

[](#dependencies)

- `tourze/wechat-mini-program-bundle` - WeChat Mini Program base functionality bundle
- `tourze/doctrine-*` - Doctrine extension bundle series
- `tourze/symfony-cron-job-bundle` - Scheduled task support
- Symfony 6.4+ components

License
-------

[](#license)

MIT

###  Health Score

33

—

LowBetter than 74% of packages

Maintenance77

Regular maintenance activity

Popularity0

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

 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 ~81 days

Total

3

Last Release

177d ago

PHP version history (2 changes)0.0.1PHP ^8.1

0.1.0PHP ^8.2

### 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-mini-program-url-link-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-wechat-mini-program-url-link-bundle/health.svg)](https://phpackages.com/packages/tourze-wechat-mini-program-url-link-bundle)
```

###  Alternatives

[sylius/sylius

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

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

Contao Open Source CMS

1231.6M2.3k](/packages/contao-core-bundle)[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)[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)[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)
