PHPackages                             lyt8384/pingpp-yii2-plus - 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. lyt8384/pingpp-yii2-plus

ActiveYii2-extension

lyt8384/pingpp-yii2-plus
========================

Simple Pingpp wrapper for Yii2

0141PHP

Since Oct 25Pushed 8y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

pingpp-Yii2-plus
================

[](#pingpp-yii2-plus)

pingxx伪基于Yii2的封装

[![Latest Stable Version](https://camo.githubusercontent.com/cbb91bfb97e1598a8ad4291b8b358563f733360266dec225d06d243f19dc64d8/68747470733a2f2f706f7365722e707567782e6f72672f6c7974383338342f70696e6770702d796969322d706c75732f762f737461626c65)](https://packagist.org/packages/lyt8384/pingpp-yii2-plus) [![Total Downloads](https://camo.githubusercontent.com/9eb3f16dbe5421a5132ddae3f68b7d88f04b30e08f05432f46487fcfc5163ca9/68747470733a2f2f706f7365722e707567782e6f72672f6c7974383338342f70696e6770702d796969322d706c75732f646f776e6c6f616473)](https://packagist.org/packages/lyt8384/pingpp-yii2-plus) [![Latest Unstable Version](https://camo.githubusercontent.com/ec3010bad4c00df162790398cc7f3b4646fc56464349ee0f7de3b114b62b6c12/68747470733a2f2f706f7365722e707567782e6f72672f6c7974383338342f70696e6770702d796969322d706c75732f762f756e737461626c65)](https://packagist.org/packages/lyt8384/pingpp-yii2-plus) [![License](https://camo.githubusercontent.com/44608f9034320137dff63c495f81a80dc25d4a3476e54918b6750d4a9e71dd04/68747470733a2f2f706f7365722e707567782e6f72672f6c7974383338342f70696e6770702d796969322d706c75732f6c6963656e7365)](https://packagist.org/packages/lyt8384/pingpp-yii2-plus)

最近主要又换Yii2开发了，其实不封装这个也是可以直接用官方那个的，只不过每次都要额外设置key什么的，搜了下，有别的大神写了一个很完善的版本，但是用起来感觉没在Laravel里那么爽，所以就把代码复制过来改了个名。这个版本的优点就是，官方SDK更新了。这边不用更新。 本人比较菜，没写单元测试，有比较在行的朋友帮补一个？

配置方法
====

[](#配置方法)

1. 在`composer.json`里添加如下内容，并运行`composer update`:

```
{
    "require": {
        "lyt8384/pingpp-yii2-plus": "dev-master"
    }
}
```

1. 在`config/web.php`文件里的components变量下添加配置

```
'pingpp' => [
    'class' => '\lyt8384\pingpp\Pingpp',
    'test_secret_key' => 'YOUR-TEST-KEY',
    'live_secret_key' => 'YOUR-LIVE-KEY',
    'live' => true,	//测试时请设置为false
    'pub_key_path' => '/path/to/pingpp_rsa_public_key.pem',	//该处不填不进行回调验证
    'private_key_path' => '/path/to/your_rsa_private_key.pem'	//该处不填不进行商家验证
],
```

使用方法
====

[](#使用方法)

```
use Yii;

class SomeClass extends Controller {

    public function someFunction()
    {
    	$pingpp = Yii::$app->pingpp;
    	$pingpp->Charge->create([
            'order_no'  => '123456789',
		    'amount'    => '100',
		    'app'       => array('id' => 'app_xxxxxxxxxxxxxx'),
		    'channel'   => 'upacp',
		    'currency'  => 'cny',
		    'client_ip' => '127.0.0.1',
		    'subject'   => 'Your Subject',
		    'body'      => 'Your Body'
        ]);
    }
}
```

```
use Yii;

class SomeClass extends Controller {

    public function someFunction()
    {
    	$pingpp = Yii::$app->pingpp;
    	$pingpp->RedEnvelope->create([
            'order_no'  => '123456789',
	        'app'       => array('id' => 'APP_ID'),
	        'channel'   => 'wx_pub',
	        'amount'    => 100,
	        'currency'  => 'cny',
	        'subject'   => 'Your Subject',
	        'body'      => 'Your Body',
	        'extra'     => array(
	            'nick_name' => 'Nick Name',
	            'send_name' => 'Send Name'
	        ),
	        'recipient'   => 'Openid',
	        'description' => 'Your Description'
        ]);
    }
}
```

错误调用
====

[](#错误调用)

当Pingpp调用发生错误的时候会`return false`，此时调用`Yii::$app->pingpp->getError();`返回具体错误内容。

接收 Webhooks 通知
==============

[](#接收-webhooks-通知)

直接调用`Yii::$app->pingpp->notice()`，若验证成功,会返回通知的`array`结构数据,若失败直接弹出错Http误回Pingpp。并产生一条Warning级别的错误日志。

IDE自动提示
=======

[](#ide自动提示)

可以按照 [IDE autocompletion for custom components](https://github.com/samdark/yii2-cookbook/blob/master/book/ide-autocompletion.md) 设置，在`Yii.php`扩展的映射下面增加`@property \lyt8384\pingpp\Pingpp $pingpp Simple Pingpp wrapper for Yii2`

其他使用方法见官方文档[PingPlusPlus](https://github.com/PingPlusPlus/pingpp-php)

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community5

Small or concentrated contributor base

Maturity41

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.

### Community

---

Top Contributors

[![lyt8384](https://avatars.githubusercontent.com/u/3069157?v=4)](https://github.com/lyt8384 "lyt8384 (6 commits)")

### Embed Badge

![Health badge](/badges/lyt8384-pingpp-yii2-plus/health.svg)

```
[![Health](https://phpackages.com/badges/lyt8384-pingpp-yii2-plus/health.svg)](https://phpackages.com/packages/lyt8384-pingpp-yii2-plus)
```

PHPackages © 2026

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