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

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

thanatosxia/yii2-wechat
=======================

WeChat SDK for yii2, based on overtrue/easywechat

1.1.2(7y ago)2197MITPHP

Since May 2Pushed 7y ago1 watchersCompare

[ Source](https://github.com/thanatos915/yii2-wechat)[ Packagist](https://packagist.org/packages/thanatosxia/yii2-wechat)[ RSS](/packages/thanatosxia-yii2-wechat/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (3)Dependencies (2)Versions (4)Used By (0)

Wechat Sdk Extension for Yii 2
==============================

[](#wechat-sdk-extension-for-yii-2)

based on [overtrue/wechat](https://github.com/overtrue/wechat)

[![Latest Stable Version](https://camo.githubusercontent.com/dbb749e7d19e7dfcf78b05fb204982251b97d6799c334820e4e1518ca2182dce/68747470733a2f2f706f7365722e707567782e6f72672f7468616e61746f737869612f796969322d7765636861742f762f737461626c65)](https://packagist.org/packages/thanatosxia/yii2-wechat)[![Total Downloads](https://camo.githubusercontent.com/9a97ee9cb945b3bf5af469c17e000d2b1decde91e2c8f0cc41e67915e5ca120d/68747470733a2f2f706f7365722e707567782e6f72672f7468616e61746f737869612f796969322d7765636861742f646f776e6c6f616473)](https://packagist.org/packages/thanatosxia/yii2-wechat)[![Latest Unstable Version](https://camo.githubusercontent.com/85bee3676fabdc05604f6060615f02e5e162674c01d9ea3dd693ac2590868328/68747470733a2f2f706f7365722e707567782e6f72672f7468616e61746f737869612f796969322d7765636861742f762f756e737461626c65)](https://packagist.org/packages/thanatosxia/yii2-wechat)

安装
--

[](#安装)

```
composer require thanatosxia/yii2-wechat
```

使用
--

[](#使用)

添加配置到main.php/config.php

```
'wechat' => [
    'class' => 'thanatos\wechat\Wechat',
    'log' => [
        'level' => 'debug',
        'permission' => '0777',
        'file' => '@runtime/logs/wechat.log'
    ],
    'app_id' => '',
    'secret' => '',
    'token' => '',
    /**
     * official 公众号
     * miniProgram 小程序
     * open 开放平台
     * weWork 企业微信
     * payment 微信支付
     */
    'app_type' => '',
],
```

对接微信

```
        $app = Yii::$app->wechat->app;

        $app->server->push(EventMessageHandle::class);

        $response = $app->server->serve();

        $response->send();
```

新建EventMessageHandle类, extends thanatos\\wechat\\MessageHandler

```
class EventMessageHandle extends MessageHandler
{
    // 在执行处理之前会被执行，如果返回false则不继续执行
    public function beforeHandle()
    {

        return parent::beforeHandle();
    }

    // 默认的消息处理方法
    public function handleDefault()
    {
        $string = 123 . Yii::$app->user->id;
        return $string;
    }

    public function getUnionid()
    {
        return $this->wechatInfo->unionid;
    }

    // 处理用户关注事件
     public function eventSubscribe()
     {

     }

}
```

对于微信的时间推荐，可以在自定义的消息处理类中添加方法，来处理 如

- `subscribe` 对应的处理方法是 `eventSubscribe`
- `scan` 对应的处理方法是 `eventScan`

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity65

Established project with proven stability

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

Total

3

Last Release

2794d ago

### Community

Maintainers

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

---

Top Contributors

[![thanatos915](https://avatars.githubusercontent.com/u/19340332?v=4)](https://github.com/thanatos915 "thanatos915 (11 commits)")

### Embed Badge

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

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

###  Alternatives

[jianyan74/yii2-easy-wechat

WeChat SDK for yii2, 基于 overtrue/easywechat

14339.4k1](/packages/jianyan74-yii2-easy-wechat)[maxwen/yii2-easy-wechat

WeChat SDK for yii2, based on overtrue/easywechat

1858.8k1](/packages/maxwen-yii2-easy-wechat)[apexwire/yii2-restclient

Tools to use API as ActiveRecord for Yii2

143.5k](/packages/apexwire-yii2-restclient)

PHPackages © 2026

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