PHPackages                             hollisho/yii2-wechat-applet - 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. hollisho/yii2-wechat-applet

ActiveLibrary

hollisho/yii2-wechat-applet
===========================

0.2.1(8y ago)32471[1 issues](https://github.com/hollisho/yii2-wechat-applet/issues)PHPPHP &gt;=5.4.0

Since Feb 25Pushed 8y ago4 watchersCompare

[ Source](https://github.com/hollisho/yii2-wechat-applet)[ Packagist](https://packagist.org/packages/hollisho/yii2-wechat-applet)[ RSS](/packages/hollisho-yii2-wechat-applet/feed)WikiDiscussions master Synced yesterday

READMEChangelog (3)DependenciesVersions (4)Used By (0)

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

[](#yii2-wechat-applet)

Yii2小程序组件 获取用户信息和会话密钥

环境需求
----

[](#环境需求)

- PHP &gt;= 5.5

安装
--

[](#安装)

```
composer require --prefer-dist hollisho/yii2-wechat-applet

```

配置
--

[](#配置)

```
return [
    //...
    'components' => [
        'applet' => [
          'class' => 'hollisho\applet\Applet',
          'appid' => 'APPID',
          'secret' => 'SECRET'
        ]
    ]
]

```

使用
--

[](#使用)

```
 $applet = Yii::$app->applet->makeSession($code);
 $applet->getUser($encryptedData, $iv); //返回用户信息
 $applet->checkSignature($rawData, $signature); //数据签名校验

 $session = $applet->getSession();
 $session->getOpenid(); //openid
 $session->getSessionKey(); //session_key
 $session->getUnionid(); //unionid

```

微信小程序api文档

快速开始
----

[](#快速开始)

小程序代码

```
wx.login({
        success: function (login) {
          wx.getUserInfo({
            success: function (res) {
              wx.request({
                url: 'xxx',
                method : 'post',
                data:{
                    code : login.code,
                    rawData : res.rawData,
                    signature : res.signature,
                    encryptedData : res.encryptedData,
                    iv : res.iv
                },
                dataType : 'json',
                success : function(res){
                }
              })
            }
          })
        }
      })

```

后端代码

```
public function actionTest(){
  $contents = file_get_contents('php://input');
  $data = json_decode($contents,true);
  $user = Yii::$app->applet
                   ->makeSession($data['code'])
                   ->getUser($data['encryptedData'],$data['iv']);
}

```

###  Health Score

25

—

LowBetter than 37% of packages

Maintenance13

Infrequent updates — may be unmaintained

Popularity16

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity50

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

Total

3

Last Release

2998d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/4e8e63d951619620f1fabe34874623212834045e7ce9b77da8e47769c6e3d7a4?d=identicon)[hollisho](/maintainers/hollisho)

---

Top Contributors

[![hollisho](https://avatars.githubusercontent.com/u/13307208?v=4)](https://github.com/hollisho "hollisho (7 commits)")

### Embed Badge

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

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

PHPackages © 2026

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