PHPackages                             tourze/wechat-mini-program-appid-contracts - 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. [PSR &amp; Standards](/categories/psr-standards)
4. /
5. tourze/wechat-mini-program-appid-contracts

ActiveLibrary[PSR &amp; Standards](/categories/psr-standards)

tourze/wechat-mini-program-appid-contracts
==========================================

微信小程序AppID定义接口

1.0.0(8mo ago)02.2k12MITPHPCI passing

Since May 10Pushed 8mo ago1 watchersCompare

[ Source](https://github.com/tourze/wechat-mini-program-appid-contracts)[ Packagist](https://packagist.org/packages/tourze/wechat-mini-program-appid-contracts)[ RSS](/packages/tourze-wechat-mini-program-appid-contracts/feed)WikiDiscussions master Synced today

READMEChangelog (2)Dependencies (3)Versions (3)Used By (12)

WeChat Mini Program AppID Contracts
===================================

[](#wechat-mini-program-appid-contracts)

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

[![PHP Version Require](https://camo.githubusercontent.com/04744bae0a61d2ffe29c26f07a9612eae20445fc6feaeb77b3af1f0e9be6447c/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253345253344382e312d3838393242462e737667)](https://packagist.org/packages/tourze/wechat-mini-program-appid-contracts)[![License](https://camo.githubusercontent.com/074b89bca64d3edc93a1db6c7e3b1636b874540ba91d66367c0e5e354c56d0ea/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e737667)](https://github.com/tourze/php-monorepo/blob/master/packages/wechat-mini-program-appid-contracts/LICENSE)[![Build Status](https://camo.githubusercontent.com/9231d504d122c0f852dec6cd6024146ca5da032c24c33fcb93630206112dc14d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f746f75727a652f7068702d6d6f6e6f7265706f2f74657374732e796d6c3f6272616e63683d6d6173746572)](https://github.com/tourze/php-monorepo/actions)[![Code Coverage](https://camo.githubusercontent.com/b7989022a434569de63853e977c1a562c9b91d8d9d02d8b940e38fca3487fec8/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f746f75727a652f7068702d6d6f6e6f7265706f2f6d61737465722e737667)](https://codecov.io/gh/tourze/php-monorepo)

This package provides interface definitions for WeChat Mini Program AppID management, offering a standardized way to handle Mini Program credentials and loaders.

Features
--------

[](#features)

- Standard interface for Mini Program credentials management
- Support for multiple Mini Program instances
- Type-safe interface definitions
- Framework-agnostic design

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

[](#installation)

Install the package via Composer:

```
composer require tourze/wechat-mini-program-appid-contracts
```

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

[](#quick-start)

### Basic Usage

[](#basic-usage)

Implement the `MiniProgramInterface` to define a Mini Program:

```
use Tourze\WechatMiniProgramAppIDContracts\MiniProgramInterface;

class MyMiniProgram implements MiniProgramInterface
{
    public function __construct(
        private string $appId,
        private string $appSecret
    ) {}

    public function getAppId(): string
    {
        return $this->appId;
    }

    public function getAppSecret(): string
    {
        return $this->appSecret;
    }
}
```

### Implementing a Loader

[](#implementing-a-loader)

Create a loader to manage multiple Mini Programs:

```
use Tourze\WechatMiniProgramAppIDContracts\MiniProgramLoaderInterface;
use Tourze\WechatMiniProgramAppIDContracts\MiniProgramInterface;

class MiniProgramLoader implements MiniProgramLoaderInterface
{
    /**
     * @var MiniProgramInterface[]
     */
    private array $programs = [];

    public function addProgram(MiniProgramInterface $program): void
    {
        $this->programs[] = $program;
    }

    /**
     * @return iterable
     */
    public function findValidList(): iterable
    {
        return $this->programs;
    }
}
```

### Usage Example

[](#usage-example)

```
// Create Mini Program instances
$program1 = new MyMiniProgram('app_id_1', 'app_secret_1');
$program2 = new MyMiniProgram('app_id_2', 'app_secret_2');

// Create and configure loader
$loader = new MiniProgramLoader();
$loader->addProgram($program1);
$loader->addProgram($program2);

// Get all valid Mini Programs
foreach ($loader->findValidList() as $program) {
    echo "AppID: " . $program->getAppId() . PHP_EOL;
}
```

API Reference
-------------

[](#api-reference)

### MiniProgramInterface

[](#miniprograminterface)

The main interface for Mini Program credentials:

- `getAppId(): string` - Returns the Mini Program's AppID
- `getAppSecret(): string` - Returns the Mini Program's App Secret

### MiniProgramLoaderInterface

[](#miniprogramloaderinterface)

Interface for loading and managing multiple Mini Programs:

- `findValidList(): iterable` - Returns an iterable collection of valid Mini Program instances

Best Practices
--------------

[](#best-practices)

1. **Security**: Never hardcode credentials in your code. Use environment variables or secure configuration management.
2. **Validation**: Implement validation in your concrete classes to ensure AppID and AppSecret are valid.
3. **Caching**: Consider caching the Mini Program list in your loader implementation for better performance.

License
-------

[](#license)

This package is open-source software licensed under the [MIT license](LICENSE).

###  Health Score

34

—

LowBetter than 75% of packages

Maintenance61

Regular maintenance activity

Popularity19

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity38

Early-stage or recently created project

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

Total

2

Last Release

246d ago

Major Versions

0.0.1 → 1.0.02025-10-31

### Community

Maintainers

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

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/tourze-wechat-mini-program-appid-contracts/health.svg)

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

###  Alternatives

[laravel/framework

The Laravel Framework.

34.8k543.8M20.1k](/packages/laravel-framework)[symfony/symfony

The Symfony PHP framework

31.4k87.2M2.2k](/packages/symfony-symfony)[symfony/framework-bundle

Provides a tight integration between Symfony components and the Symfony full-stack framework

3.6k251.7M11.6k](/packages/symfony-framework-bundle)[symfony/security-bundle

Provides a tight integration of the Security component into the Symfony full-stack framework

2.5k185.6M2.4k](/packages/symfony-security-bundle)[symfony/web-profiler-bundle

Provides a development tool that gives detailed information about the execution of any request

2.3k160.5M1.2k](/packages/symfony-web-profiler-bundle)[behat/behat

Scenario-oriented BDD framework for PHP

4.0k101.8M2.2k](/packages/behat-behat)

PHPackages © 2026

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