PHPackages                             tourze/coupon-h5-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. tourze/coupon-h5-link-bundle

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

tourze/coupon-h5-link-bundle
============================

为优惠券系统提供H5外链功能的Symfony Bundle

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

Since Jun 1Pushed 4mo agoCompare

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

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

Coupon H5 Link Bundle
=====================

[](#coupon-h5-link-bundle)

[![PHP Version](https://camo.githubusercontent.com/cc9cdea9aa96b40a822425e981b0a030e3371202973c7d57b74e8e99834f81dc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e312d626c7565)](https://php.net)[![Symfony Version](https://camo.githubusercontent.com/957f1ae5a99032b32272317293f424a739011fe26ad30ce440da6055dfe538b2/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f73796d666f6e792d253545372e332d677265656e)](https://symfony.com)[![License](https://camo.githubusercontent.com/7013272bd27ece47364536a221edb554cd69683b68a46fc0ee96881174c4214c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d626c75652e737667)](LICENSE)[![Build Status](https://camo.githubusercontent.com/c27a457659b89ee4f1f80f7995c559dd37f2051bde7167ad25791e5c5c92cc8e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6275696c642d70617373696e672d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo)[![Coverage Status](https://camo.githubusercontent.com/b3545ae1bcdb4ea486f71f87b43001e82dd21933bc8035d44601706c851265da/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f636f7665726167652d3130302532352d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo)

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

A Symfony bundle for managing H5 coupon external links, providing entity management and repository functionality for H5 link operations.

Features
--------

[](#features)

- H5 external link entity management
- Integration with coupon core system
- Built-in timestamp, blame, and IP tracking
- API serialization support
- Doctrine ORM integration

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

[](#installation)

Install the package via Composer:

```
composer require tourze/coupon-h5-link-bundle
```

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

[](#quick-start)

### 1. Register the Bundle

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

Add the bundle to your `config/bundles.php`:

```
return [
    // ...
    Tourze\CouponH5LinkBundle\CouponH5LinkBundle::class => ['all' => true],
];
```

### 2. Create and Configure H5 Link Entity

[](#2-create-and-configure-h5-link-entity)

```
use Tourze\CouponH5LinkBundle\Entity\H5Link;
use Tourze\CouponCoreBundle\Entity\Coupon;

// Create a new H5 link
$h5Link = new H5Link();
$h5Link->setUrl('https://example.com/coupon-page');
$h5Link->setCoupon($coupon); // Associate with a coupon

// Save to database
$entityManager->persist($h5Link);
$entityManager->flush();
```

### 3. Using the Repository

[](#3-using-the-repository)

```
use Tourze\CouponH5LinkBundle\Repository\H5LinkRepository;

// Inject the repository
public function __construct(
    private H5LinkRepository $h5LinkRepository
) {}

// Find H5 links
$h5Links = $this->h5LinkRepository->findAll();
```

### 4. API Serialization

[](#4-api-serialization)

The H5Link entity implements `ApiArrayInterface` for easy API responses:

```
$h5Link = new H5Link();
$h5Link->setUrl('https://example.com/coupon');

// Get API array representation
$apiData = $h5Link->retrieveApiArray();
// Returns: [
//     'id' => 12345,
//     'createTime' => '2024-01-01 12:00:00',
//     'updateTime' => '2024-01-01 12:00:00',
//     'url' => 'https://example.com/coupon'
// ]
```

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

[](#advanced-usage)

### Custom Repository Methods

[](#custom-repository-methods)

Extend the H5LinkRepository to add custom query methods:

```
use Tourze\CouponH5LinkBundle\Repository\H5LinkRepository;
use Doctrine\Persistence\ManagerRegistry;

class CustomH5LinkRepository extends H5LinkRepository
{
    public function findByCouponType(string $type): array
    {
        return $this->createQueryBuilder('h')
            ->join('h.coupon', 'c')
            ->where('c.type = :type')
            ->setParameter('type', $type)
            ->getQuery()
            ->getResult();
    }
}
```

### Validation and Security

[](#validation-and-security)

The H5Link entity includes built-in validation constraints:

```
// URL validation ensures proper format
// Length constraint prevents database overflow
// NotBlank ensures required field is filled

// Custom validation can be added via events or custom constraints
```

### Event Integration

[](#event-integration)

Listen to H5Link entity changes:

```
use Doctrine\Bundle\DoctrineBundle\Attribute\AsEntityListener;
use Doctrine\ORM\Events;
use Tourze\CouponH5LinkBundle\Entity\H5Link;

#[AsEntityListener(event: Events::prePersist, entity: H5Link::class)]
class H5LinkListener
{
    public function prePersist(H5Link $h5Link): void
    {
        // Custom logic before saving
        $this->validateUrl($h5Link->getUrl());
    }
}
```

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

[](#configuration)

The bundle automatically configures the necessary services. No additional configuration is required.

Entity Features
---------------

[](#entity-features)

### H5Link Entity

[](#h5link-entity)

The `H5Link` entity provides:

- **id**: Snowflake ID for unique identification
- **url**: The H5 external link URL
- **coupon**: One-to-one relationship with Coupon entity
- **createTime/updateTime**: Automatic timestamps
- **createdBy/updatedBy**: User tracking
- **createIp/updateIp**: IP address tracking

### Traits Used

[](#traits-used)

- `SnowflakeKeyAware`: Provides snowflake-based ID generation
- `TimestampableAware`: Automatic creation and update timestamps
- `BlameableAware`: Track user who created/updated the entity
- `IpTraceableAware`: Track IP addresses for creation/updates

Requirements
------------

[](#requirements)

- PHP 8.1 or higher
- Symfony 7.3 or higher
- Doctrine ORM 3.0 or higher

License
-------

[](#license)

This bundle is released under the MIT License. See the [LICENSE](LICENSE) file for details.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance64

Regular maintenance activity

Popularity0

Limited adoption so far

Community6

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

346d 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-coupon-h5-link-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/tourze-coupon-h5-link-bundle/health.svg)](https://phpackages.com/packages/tourze-coupon-h5-link-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)[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)
