PHPackages                             lspbupt/yii2-wechat - 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. [API Development](/categories/api)
4. /
5. lspbupt/yii2-wechat

ActiveYii2-extension[API Development](/categories/api)

lspbupt/yii2-wechat
===================

The wechat-sdk for Yii2 framework

9922PHP

Since Mar 19Pushed 5y ago1 watchersCompare

[ Source](https://github.com/buptlsp/yii2-wechat)[ Packagist](https://packagist.org/packages/lspbupt/yii2-wechat)[ RSS](/packages/lspbupt-yii2-wechat/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependenciesVersions (1)Used By (0)

yii2-wechat
===========

[](#yii2-wechat)

环境条件
----

[](#环境条件)

- php5.4或更高
- Yii2

安装
--

[](#安装)

您可以使用composer来安装, 添加下列代码在您的`composer.json`文件中并执行`composer update`操作

```
{
    "require": {
       "lspbupt/yii2-wechat": "dev-master"
    }
}
```

或者

```
composer require lspbupt/yii2-wechat dev-master

```

主要功能
----

[](#主要功能)

在正常的业务开发过程中，和微信的对接是一个极为繁琐的事情，本软件力求将微信的对接封装起来，对外提供一个方便，舒适的开发过程，尽力降低与微信对接的难度。目前主要实现了如下内容：

- [微信公众号对接](docs/Wechat.md)
- [微信h5支付对接](docs/WxPay.md)
- [微信小程序对接](docs/WxSmallApp.md)
- [外部网站微信内登录对接](docs/WxLogin.md)
- [外部网站微信扫码登录对接](docs/WxApp.md)

大致说明
----

[](#大致说明)

### 后端对接

[](#后端对接)

所有与微信后端对接的接口的使用，大致的流程均是一样的过程, 具体的可以参见前文中相应的链接：

1.注入component, 这个component是我们跟微信的桥梁，

```
    return [
        'component' => [
            // ...
            'wechat' => [
                'class' => 'xxx', // 具体对接的类，如：ethercap/Wechat::class,
                'appid' => 'xxx',
                'appsecret' => 'xxx',
            ],
            //  其它配置
        ],
    ];
```

2.上面的配置好之后，就可以直接通过如下实例请求微信接口了。

```
$ret = Yii::$app->wechat->httpExec('xxx', []);
```

在请求发起时，会自动从cache中读取access\_token，并发出请求。如果cache中不存在，会通过微信的接口，获取access\_token。用户完全不需要关心微信access\_token的事情，也不需要关心加密的问题。

### 前端对接

[](#前端对接)

所有与微信前端对接，大致的流程也均是一样的,我们只需要在前端的页面上放入如下的内容就能完全前端的对接，不需要繁琐的jsapi计算：

```
// 具体的类详见上文中具体对接的文档
echo JSxxxConfig:: widget([
    'debug' => false, //true代表打开前端调试
    'wechat' => 'wechat', //具体的实例，对应上一节的配置名，默认为wechat
    'successJs' => 'function(){console.log("success")}', //js校验成功时的回调
    'errorJs' => 'function(){console.log("error")}', //js校验失败时的回调
    'jsApiList' => [], //需要在本页中调用的js接口
]);
```

广告
--

[](#广告)

我们是一群热爱技术，追求卓越的极客，我们乐于做一些对整个社会都有作用的事情，我们希望通过我们的努力来推动整个社会的创新，如果你也一样，欢迎加入我们（）！你也可以通过 来了解更多！

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity30

Early-stage or recently created project

 Bus Factor1

Top contributor holds 50% 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.

### Community

Maintainers

![](https://www.gravatar.com/avatar/c03647179c868e4c565f848f22a2a7642f423084946b85d8c85b918798f4c3a7?d=identicon)[lspbupt](/maintainers/lspbupt)

---

Top Contributors

[![buptlsp](https://avatars.githubusercontent.com/u/3291512?v=4)](https://github.com/buptlsp "buptlsp (3 commits)")[![zhihuacui](https://avatars.githubusercontent.com/u/6275695?v=4)](https://github.com/zhihuacui "zhihuacui (2 commits)")[![koenigseggposche](https://avatars.githubusercontent.com/u/3244182?v=4)](https://github.com/koenigseggposche "koenigseggposche (1 commits)")

---

Tags

smallappwechatyii2yii2-extension

### Embed Badge

![Health badge](/badges/lspbupt-yii2-wechat/health.svg)

```
[![Health](https://phpackages.com/badges/lspbupt-yii2-wechat/health.svg)](https://phpackages.com/packages/lspbupt-yii2-wechat)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[facebook/php-business-sdk

PHP SDK for Facebook Business

90821.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

74513.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

265103.1M454](/packages/google-gax)[google/common-protos

Google API Common Protos for PHP

173103.7M50](/packages/google-common-protos)

PHPackages © 2026

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