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

ActiveLibrary[API Development](/categories/api)

elim051/yii2-wechat
===================

WeChat SDK for yii2, based on overtrue/easywechat

v0.2(8y ago)08MITPHP

Since Jan 17Pushed 8y ago1 watchersCompare

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

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

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

[](#yii2-wechat)

WeChat SDK for yii2 , based on [overtrue/wechat](https://github.com/overtrue/wechat).
This extension helps you access `overtrue/wechat` application in a simple &amp; familiar way: `Yii::$app->wechat`.

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

[](#installation)

```
composer require elim051/yii2-wechat
或者将下边这个行代码加入到你的composer.json的require中
"elim051/yii2-wechat": "*"

```

Configuration
-------------

[](#configuration)

Add the SDK as a yii2 application `component` in the `config/main.php`:

```
'components' => [
    // ...
    'wechat' => [
        'class' => 'elim051\easywechat\Wechat',
        'config' => [  // easywechat configurations
            'app_id' => 'wx3cf0f39249eb0exx',
            'secret' => 'f1c242f4f28f735d4687abb469072axx',

            // 指定 API 调用返回结果的类型：array(default)/collection/object/raw/自定义类名
            'response_type' => 'array',

            'log' => [
                'level' => 'debug',
                'file' => __DIR__.'/wechat.log',
            ],
        ]
        // 'sessionParam' => '' # wechat user info will be stored in session under this key
        // 'returnUrlParam' => '' # returnUrl param stored in session
    ],
    // ...
]
```

Usage
-----

[](#usage)

```
// here are two representative examples that will help you:

// 微信网页授权:
if(Yii::$app->wechat->isWechat && !Yii::$app->wechat->isAuthorized()) {
    return Yii::$app->wechat->authorizeRequired()->send();
}

// 自定义scopes
if(Yii::$app->wechat->isWechat && !Yii::$app->wechat->isAuthorized()) {
    Yii::$app->wechat->scopes = ['snsapi_userinfo'];
    return Yii::$app->wechat->authorizeRequired()->send();
}

// 微信支付(JsApi):
$orderData = [
    'openid' => '.. '
    // ... etc.
];
$order = new WechatOrder($orderData);
$payment = Yii::$app->wechat->payment;
$prepayRequest = $payment->prepare($order);
if($prepayRequest->return_code = 'SUCCESS' && $prepayRequest->result_code == 'SUCCESS') {
	$prepayId = $prepayRequest->prepay_id;
}else{
	throw new yii\base\ErrorException('微信支付异常, 请稍后再试');
}

$jsApiConfig = $payment->configForPayment($prepayId);

return $this->render('wxpay', [
	'jsApiConfig' => $jsApiConfig,
	'orderData'   => $orderData
]);
```

[Wechat options configure help docs.](https://easywechat.org/zh-cn/docs/configuration.html)

### More documentation

[](#more-documentation)

see [EasyWeChat Docs](https://easywechat.org/zh-cn/docs/index.html).

Thanks to `overtrue/wechat` , realy a easy way to play with wechat SDK 😁. Thanks to `maxwen/yii2-easy-wechat` 😁.

###  Health Score

23

—

LowBetter than 27% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity4

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity54

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

2

Last Release

3036d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/506b3cce7328906b65158cb0bff5054b28cd895ab5772739779799abdadae157?d=identicon)[elim051](/maintainers/elim051)

---

Top Contributors

[![elim051](https://avatars.githubusercontent.com/u/6869709?v=4)](https://github.com/elim051 "elim051 (5 commits)")

### Embed Badge

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

```
[![Health](https://phpackages.com/badges/elim051-yii2-wechat/health.svg)](https://phpackages.com/packages/elim051-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)
