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(6mo ago)02.2k12MITPHPCI passing

Since May 10Pushed 6mo 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 1mo ago

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

36

—

LowBetter than 81% of packages

Maintenance72

Regular maintenance activity

Popularity15

Limited adoption so far

Community13

Small or concentrated contributor base

Maturity37

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

190d ago

Major Versions

0.0.1 → 1.0.02025-10-31

### Community

Maintainers

![](https://www.gravatar.com/avatar/e354fdb316da535dfa8ba2e9193a473c403b6bc6fb9170778d1dc50e304c6e9d?d=identicon)[tourze](/maintainers/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

[phpdocumentor/type-resolver

A PSR-5 based resolver of Class names, Types and Structural Element Names

9.2k719.5M166](/packages/phpdocumentor-type-resolver)[pimple/pimple

Pimple, a simple Dependency Injection Container

2.7k130.5M1.4k](/packages/pimple-pimple)[league/container

A fast and intuitive dependency injection container.

86387.8M342](/packages/league-container)[stella-maris/clock

A pre-release of the proposed PSR-20 Clock-Interface

7947.5M2](/packages/stella-maris-clock)[wptrt/wpthemereview

PHP\_CodeSniffer rules (sniffs) to verify theme compliance with the rules for theme hosting on wordpress.org

217736.5k29](/packages/wptrt-wpthemereview)[inpsyde/modularity

Modular PSR-11 implementation for WordPress plugins, themes or libraries.

54383.3k3](/packages/inpsyde-modularity)

PHPackages © 2026

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