PHPackages                             takatost/laravel\_wechat\_open\_platform - 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. takatost/laravel\_wechat\_open\_platform

ActiveLibrary[API Development](/categories/api)

takatost/laravel\_wechat\_open\_platform
========================================

Wechat Open Platform Package For Laravel

1.0.3(9y ago)56924MITPHP

Since Aug 9Pushed 9y ago2 watchersCompare

[ Source](https://github.com/takatost/laravel_wechat_open_platform)[ Packagist](https://packagist.org/packages/takatost/laravel_wechat_open_platform)[ RSS](/packages/takatost-laravel-wechat-open-platform/feed)WikiDiscussions master Synced yesterday

READMEChangelogDependencies (1)Versions (5)Used By (0)

laravel\_wechat\_open\_platform
===============================

[](#laravel_wechat_open_platform)

Wechat Open Platform Package For Laravel

Install
-------

[](#install)

1. Composer Install

```
composer require "takatost/laravel_wechat_open_platform:~1.0"
```

> 为了保证模块正常使用，请禁用 laravel-debugbar。

配置
--

[](#配置)

### Laravel 应用

[](#laravel-应用)

1. 注册 `ServiceProvider`:

```
LaravelWechatOP\ServiceProvider::class,
```

2. 创建配置文件：

```
php artisan vendor:publish
```

3. 请修改应用根目录下的 `config/wechat_op.php` 中对应的项即可；
4. （可选）添加外观到 `config/app.php` 中的 `aliases` 部分:

```
'WechatOP' => LaravelWechatOP\WechatOP::class,
```

使用
--

[](#使用)

授权流程详见：[开放平台文档](https://open.weixin.qq.com/cgi-bin/showdocument?action=dir_list&t=resource/res_list&verify=1&id=open1453779503&token=&lang=zh_CN)我们可以通过 `app('wechat_op')` 或外观 `WechatOP`来获取开放平台应用对象。

### 跳转公众号授权页

[](#跳转公众号授权页)

```
$callbackUrl = 'http://for.bar/callback'; // 授权回调地址
$response = WechatOP::oauth()->redirect($callbackUrl);  // 或 $response = app('wechat_op')->oauth->redirect($authCallbackUrl);
// 获取跳转地址 $redirectUrl = $response->getTargetUrl();

return $response;

```

### 授权回调信息获取

[](#授权回调信息获取)

授权后需要记录公众号的 `appid` 和 `authorizer_refresh_token` 以代公众号实现业务。

```
$authInfo = WechatOP::oauth()->user();
/**
{
  "id": "appid",
  "name": "公众号名称",
  "nickname": "公众号名称",
  "avatar": "公众号头像",
  "email": null,
  "authorizer_info": {
    "nick_name": "公众号名称",
    "head_img": "公众号头像",
    "service_type_info": {
      "id": 2
    },
    "verify_type_info": {
      "id": 0
    },
    "user_name": "公众号ID",
    "business_info": {
      "open_store": 1,
      "open_scan": 1,
      "open_pay": 1,
      "open_card": 1,
      "open_shake": 1
    },
    "alias": "公众号别名"
  },
  "qrcode_url": "公众号二维码图片地址",
  "authorization_info": {
    "authorizer_appid": "appid",
    "authorizer_access_token": "authorizer_access_token",
    "expires_in": 7200,
    "authorizer_refresh_token": "authorizer_refresh_token",
    "func_info": [
      {
        "funcscope_category": {
          "id": 1
        }
      },
      {
        "funcscope_category": {
          "id": 2
        }
      },
      {
        "funcscope_category": {
          "id": 3
        }
      }
    ]
  }
}
**/

```

### 接收事件

[](#接收事件)

```
$server = WechatOP::server();
$server->setMessageHandler(function($message) {
        switch ($message->get('InfoType')) {
            case "component_verify_ticket":
                // 保存开放平台 ticket
                env('wechat_op')->saveTicket($message->get('ComponentVerifyTicket'));
                break;
            case "unauthorized":
                // 公众号取消授权记录
                break;
            default:
                break;
        }
    });

return $server->serve();

```

### 代公众号实现业务

[](#代公众号实现业务)

每个平台下的公众号都需要单独传入配置

```
$options = [
        'app_id'    => '公众号 app_id',
        'secret'    => '公众号 secret',   // 仅适用于 单独配置公众号
        'token'     => '公众号 token',   // 仅适用于 单独配置公众号
        'aes_key'   => '公众号 aes_key',   // 仅适用于 单独配置公众号
        'auth_type' => 'COMPONENT', // COMPONENT 开放平台授权公众号，MANUAL 单独配置公众号
        'component_refresh_token' => 'component_refresh_token',   // 授权回调时获取的 authorizer_refresh_token，仅适用于 开放品台授权公众号
        'oauth'     => [
            'scopes' => ['snsapi_base'] // 公众号授权用户方式 snsapi_base, snsapi_userinfo
        ],
    ];

$wechatApp = WechatOP::app($options);

```

`$wechatApp` 为 `EasyWechat\Foundation\Application` 对象，使用方式见 [EasyWeChat 文档](https://easywechat.org/zh-cn/docs/)

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity20

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity66

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

Total

4

Last Release

3605d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/5485478?v=4)[takatost](/maintainers/takatost)[@takatost](https://github.com/takatost)

---

Top Contributors

[![takatost](https://avatars.githubusercontent.com/u/5485478?v=4)](https://github.com/takatost "takatost (9 commits)")

---

Tags

laravelsdkwechatweixinopen platformwechat-open-platform

### Embed Badge

![Health badge](/badges/takatost-laravel-wechat-open-platform/health.svg)

```
[![Health](https://phpackages.com/badges/takatost-laravel-wechat-open-platform/health.svg)](https://phpackages.com/packages/takatost-laravel-wechat-open-platform)
```

###  Alternatives

[overtrue/laravel-wechat

微信 SDK for Laravel

2.9k1.8M54](/packages/overtrue-laravel-wechat)[itxiao6/wechat

MinKernel.Wechat

1062.8k](/packages/itxiao6-wechat)

PHPackages © 2026

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