PHPackages                             lyle-lai/wxxcx - 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. lyle-lai/wxxcx

ActiveLibrary[API Development](/categories/api)

lyle-lai/wxxcx
==============

A WeChat applet (xiaochengxu) plugins for Laravel 5. Fork from github.com/lanceWan/wxxcx

v2.1(8y ago)015MITPHPPHP &gt;=5.5.9

Since May 27Pushed 8y ago1 watchersCompare

[ Source](https://github.com/LyleLai/wxxcx)[ Packagist](https://packagist.org/packages/lyle-lai/wxxcx)[ RSS](/packages/lyle-lai-wxxcx/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (1)Dependencies (1)Versions (4)Used By (0)

Laravel 5 微信小程序扩展
=================

[](#laravel-5-微信小程序扩展)

> 小程序官方的加解密 SDK 已经非常清楚了，只不过改成 Laravel 风格而已，仅仅相当于搬砖工。至于重复造轮子，我发现其他人的扩展解密用户信息的时候代码出错了，并且需要安装一个 Laravel 的 Curl 扩展也没说。只好自己去根据他们的源码自己写一个0.0 ，不依赖其他扩展，直接安装使用即可。

小程序API接口
--------

[](#小程序api接口)

- 用户登录：[wx.login](https://mp.weixin.qq.com/debug/wxadoc/dev/api/api-login.html)
- 获取用户信息：[wx.getUserInfo](https://mp.weixin.qq.com/debug/wxadoc/dev/api/open.html#wxgetuserinfoobject)

安装
--

[](#安装)

> 由于 PHP7.1 的加密函数 `mcrypt_module_open()` 因为过时而被废弃。使用 PHP7.1 版本的人请安装 2.0 版本的代码

执行以下命令安装最新稳定版本:

**PHP &lt; 7.1**

```
composer require iwanli/wxxcx=1.*
```

**PHP &gt; 7.1**

```
composer require iwanli/wxxcx=2.*
```

或者添加如下信息到你的 `composer.json` 文件中 :

**PHP &lt; 7.1**

```
"iwanli/wxxcx": "^1.0"
```

**PHP &gt; 7.1**

```
"iwanli/wxxcx": "^2.0"
```

然后注册服务提供者到 Laravel中 具体位置：`/config/app.php` 中的 `providers` 数组:

```
Iwanli\Wxxcx\WxxcxServiceProvider::class,
```

发布配置文件:

```
php artisan vendor:publish --tag=wxxcx
```

命令完成后，会添加一个`wxxcx.php`配置文件到您的配置文件夹 如 : `/config/wxxcx.php`。

生成配置文件后，将小程序的 `AppID` 和 `AppSecret` 填写到 `/config/wxxcx.php` 文件中

在Laravel 5控制器中使用 (示例)
---------------------

[](#在laravel-5控制器中使用-示例)

```
...

use Iwanli\Wxxcx\Wxxcx;

class WxxcxController extends Controller
{
    protected $wxxcx;

    function __construct(Wxxcx $wxxcx)
    {
        $this->wxxcx = $wxxcx;
    }

    /**
     * 小程序登录获取用户信息
     * @author 晚黎
     * @date   2017-05-27T14:37:08+0800
     * @return [type]                   [description]
     */
    public function getWxUserInfo()
    {
        //code 在小程序端使用 wx.login 获取
        $code = request('code', '');
        //encryptedData 和 iv 在小程序端使用 wx.getUserInfo 获取
        $encryptedData = request('encryptedData', '');
        $iv = request('iv', '');

        //根据 code 获取用户 session_key 等信息, 返回用户openid 和 session_key
        $userInfo = $this->wxxcx->getLoginInfo($code);

        //获取解密后的用户信息
        return $this->wxxcx->getUserInfo($encryptedData, $iv);
    }
}
```

用户信息返回格式:

```
{
    "openId": "xxxx",
    "nickName": "晚黎",
    "gender": 1,
    "language": "zh_CN",
    "city": "",
    "province": "Shanghai",
    "country": "CN",
    "avatarUrl": "http://wx.qlogo.cn/mmopen/xxxx",
    "watermark": {
        "timestamp": 1495867603,
        "appid": "your appid"
    }
}

```

小程序端获取 code、iv、encryptedData 向服务端发送请求示例代码：
------------------------------------------

[](#小程序端获取-codeivencrypteddata-向服务端发送请求示例代码)

```
//调用登录接口
wx.login({
    success: function (response) {
        var code = response.code
        wx.getUserInfo({
            success: function (resp) {
                wx.request({
                    url: 'your domain',
                    data: {
                        code: code,
                        iv: resp.iv,
                        encryptedData: resp.encryptedData
                    },
                    success: function (res) {
                        console.log(res.data)
                    }
                })
            }
        })
    },
    fail:function(){
        ...
    }
})
```

> 如有bug，请在 [Issues](https://github.com/lanceWan/wxxcx/issues) 中反馈，非常感谢！

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity60

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

Total

3

Last Release

3241d ago

Major Versions

v1.0 → v2.02017-06-08

### Community

Maintainers

![](https://www.gravatar.com/avatar/8d11fd99a6801db983090234bafb7fd9c11a2f573742e5140f9cd54df80e9322?d=identicon)[LyleLai](/maintainers/LyleLai)

---

Top Contributors

[![LyleLai](https://avatars.githubusercontent.com/u/15356670?v=4)](https://github.com/LyleLai "LyleLai (1 commits)")

### Embed Badge

![Health badge](/badges/lyle-lai-wxxcx/health.svg)

```
[![Health](https://phpackages.com/badges/lyle-lai-wxxcx/health.svg)](https://phpackages.com/packages/lyle-lai-wxxcx)
```

###  Alternatives

[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)[mll-lab/laravel-graphiql

Easily integrate GraphiQL into your Laravel project

683.2M9](/packages/mll-lab-laravel-graphiql)[spatie/laravel-route-discovery

Auto register routes using PHP attributes

23645.0k2](/packages/spatie-laravel-route-discovery)[esign/laravel-conversions-api

A laravel wrapper package around the Facebook Conversions API

69145.4k](/packages/esign-laravel-conversions-api)[didww/didww-api-3-php-sdk

PHP SDK for DIDWW API 3

1218.2k](/packages/didww-didww-api-3-php-sdk)[surface/laravel-webfinger

A Laravel package to create an ActivityPub webfinger.

113.8k](/packages/surface-laravel-webfinger)

PHPackages © 2026

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