PHPackages                             chenall/phalapi-weixin - 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. chenall/phalapi-weixin

ActiveLibrary[API Development](/categories/api)

chenall/phalapi-weixin
======================

PhalApi 2.x 扩展类库：微信公众号、企业号等开发扩展

1.0.0(8y ago)6184↓75%3GPL-3.0+PHPPHP &gt;=7.0

Since May 31Pushed 7y ago1 watchersCompare

[ Source](https://github.com/chenall/phalapi-weixin)[ Packagist](https://packagist.org/packages/chenall/phalapi-weixin)[ Docs](https://www.phalapi.net/)[ RSS](/packages/chenall-phalapi-weixin/feed)WikiDiscussions master Synced 2w ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

微信扩展 \\PhalApi\\WeiXin
----------------------

[](#微信扩展-phalapiweixin)

微信公众号、企业号等开发扩展, 使用[Eastwechat](https://www.easywechat.com)。

```
new \PhalApi\WeiXin\Lite(服务名);
```

1. 支持公众号、企业微信等，具体参考[Eastwechat文档](https://www.easywechat.com/docs),传入不同的服务名就可以调用不同的服务。
2. 只是简单的提供了一个调用方法，内置默认服务。
3. 目前该扩展我主要是用于企业微信，本文的例子也都是企业微信，传入的服务名为`Work`;
4. 扩展msg目录里面的类是为了支持IDE友好提示而设立的。

### 安装

[](#安装)

在项目下直接运行以下命令即可完成扩展安装。

```
composer require overtrue/wechat:~4.0 -vvv
composer require chenall/phalapi-weixin

```

### 配置

[](#配置)

根据要使用的不同的服务类型添加相应的配置文件 配置文件名 **wx\_服务名.php**本例为企业微信

配置文件./Config/wx\_Work.php

```
return array(
    /**
     * 扩展类库 - 微信公众号配置
     * 注： 具体配置参数请参考 https://www.easywechat.com/docs
     */
    'corp_id' => 'xxxxxxxxxxxxxxxxx',

    'agent_id' => 100020, // 如果有 agend_id 则填写
    'secret'   => 'xxxxxxxxxx',

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

    'log' => [
        'level' => 'debug',
        'file' => __DIR__.'/wechat.log',
    ],
);
```

### 注册

[](#注册)

在./config/di.php文件中，注册微信服务(可以按需注册多个服务);

```
//企业微信
$di->wxWork = function(){
    $weixin = new \PhalApi\WeiXin\Lite('Work');
    return $weixin->wxApp();
};
//公众号
$di->officialAccount = function(){
    $weixin = new \PhalApi\WeiXin\Lite('officialAccount');
    return $weixin->wxApp();
};
```

### 服务端访问入口(消息接收处理,需要单独的访问入口)

[](#服务端访问入口消息接收处理需要单独的访问入口)

需要对接收的信息进行处理时才需要使用

```
//./Public/WeiXin.php
/**
 * 统一访问入口
 */
require_once dirname(__FILE__) . '/init.php';

$server = new \PhalApi\WeiXin\Lite('Work');
//默认使用内置的消息处理 \PhalApi\WeiXin\Server
$server->response();
```

也可以使用自己定义的消息处理接口

```
//./Public/WeiXin.php
/**
 * 统一访问入口
 */
require_once dirname(__FILE__) . '/init.php';

$server = new \PhalApi\WeiXin\Lite('Work');
$server->response('\\WeiXin\\Work\\Server');
```

```
//可以直接扩展\PhalApi\WeiXin\Server，也可以完全自己实现
class Server extends \PhalApi\WeiXin\Server {
    public function text($message){
        .....
        //消息类型 可以返回各种消息类型，比如图片，文本等，具体的使用方法参考说明文档
        return 要返回给消息发送者的信息;
    }
}
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity58

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

Unknown

Total

1

Last Release

2951d ago

### Community

Maintainers

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

---

Top Contributors

[![chenall](https://avatars.githubusercontent.com/u/628011?v=4)](https://github.com/chenall "chenall (3 commits)")

---

Tags

phalapiphalapi-weixin

### Embed Badge

![Health badge](/badges/chenall-phalapi-weixin/health.svg)

```
[![Health](https://phpackages.com/badges/chenall-phalapi-weixin/health.svg)](https://phpackages.com/packages/chenall-phalapi-weixin)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

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