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

ActiveLibrary

maxwen/yii2-easy-wechat
=======================

WeChat SDK for yii2, based on overtrue/easywechat

1.0.3(8y ago)1858.8k↓100%56[6 issues](https://github.com/max-wen/yii2-easy-wechat/issues)1MITPHP

Since Oct 25Pushed 8y ago10 watchersCompare

[ Source](https://github.com/max-wen/yii2-easy-wechat)[ Packagist](https://packagist.org/packages/maxwen/yii2-easy-wechat)[ RSS](/packages/maxwen-yii2-easy-wechat/feed)WikiDiscussions master Synced today

READMEChangelog (8)Dependencies (2)Versions (10)Used By (1)

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

[](#yii2-easy-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`.

[![Latest Stable Version](https://camo.githubusercontent.com/132cd820c740255268671aab73595cfaef31088cead503f90348e2f7e1bc94bd/68747470733a2f2f706f7365722e707567782e6f72672f6d617877656e2f796969322d656173792d7765636861742f762f737461626c65)](https://packagist.org/packages/maxwen/yii2-easy-wechat)[![Total Downloads](https://camo.githubusercontent.com/3129617282a6f7c7e9361d80398b2aa4c010d800f75ad3c82457b1b7e63c7f89/68747470733a2f2f706f7365722e707567782e6f72672f6d617877656e2f796969322d656173792d7765636861742f646f776e6c6f616473)](https://packagist.org/packages/maxwen/yii2-easy-wechat)[![License](https://camo.githubusercontent.com/5dded256cb33e3c2048bac67e29b234f547458dd05be61d487bcc09be943fa55/68747470733a2f2f706f7365722e707567782e6f72672f6d617877656e2f796969322d656173792d7765636861742f6c6963656e7365)](https://packagist.org/packages/maxwen/yii2-easy-wechat)

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

[](#installation)

```
composer require maxwen/yii2-easy-wechat

```

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

[](#configuration)

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

```
'components' => [
	// ...
	'wechat' => [
		'class' => 'maxwen\easywechat\Wechat',
		// 'userOptions' => []  # user identity class params
		// '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();
}

// 微信支付(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
]);
```

### How to load Wechat configures?

[](#how-to-load-wechat-configures)

the `overtrue/wechat` application always constructs with a `$options` parameter. I made the options as a yii2 param in the `params.php`:

recomended way:

```
// in this way you need to create a wechat.php in the same directory of params.php
// put contents in the wechat.php like:
// return [
// 		// wechat options here
// ];
'WECHAT' => require(__DIR__.'/wechat.php'),
```

OR

```
'WECHAT' => [ // wechat options here ]
```

[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 😁.

More repos for Yii2:
--------------------

[](#more-repos-for-yii2)

[yii2-ckeditor-widget](https://github.com/max-wen/yii2-ckeditor-widget)
[yii2-adminlte-gii](https://github.com/max-wen/yii2-adminlte-gii)
[yii2-curl](https://github.com/max-wen/yii2-curl)

###  Health Score

41

—

FairBetter than 89% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity40

Moderate usage in the ecosystem

Community22

Small or concentrated contributor base

Maturity69

Established project with proven stability

 Bus Factor1

Top contributor holds 60% 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 ~36 days

Recently: every ~68 days

Total

9

Last Release

3145d ago

Major Versions

0.9.3 → 1.02016-11-13

1.0.2 → 2.x-dev2017-04-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/dea29ab3f737decc3534de372cc6bf5beb19843ae09802480c77307fed7d3117?d=identicon)[max.wen](/maintainers/max.wen)

---

Top Contributors

[![imaxwen](https://avatars.githubusercontent.com/u/2849142?v=4)](https://github.com/imaxwen "imaxwen (12 commits)")[![max-wen](https://avatars.githubusercontent.com/u/116544153?v=4)](https://github.com/max-wen "max-wen (6 commits)")[![jonneyless](https://avatars.githubusercontent.com/u/1261839?v=4)](https://github.com/jonneyless "jonneyless (2 commits)")

---

Tags

wechatwechat-sdkyiiyii-wechat

### Embed Badge

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

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

###  Alternatives

[jianyan74/yii2-easy-wechat

WeChat SDK for yii2, 基于 overtrue/easywechat

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

PHPackages © 2026

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