PHPackages                             achais/laravel-wechat-reply - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. achais/laravel-wechat-reply

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

achais/laravel-wechat-reply
===========================

Wechat reply handing for Laravel 5.5 and up

v1.1.1(5y ago)4841MITJavaScriptPHP &gt;=7.0CI failing

Since Apr 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/achais/laravel-wechat-reply)[ Packagist](https://packagist.org/packages/achais/laravel-wechat-reply)[ Docs](https://github.com/achais/laravel-wechat-reply)[ RSS](/packages/achais-laravel-wechat-reply/feed)WikiDiscussions master Synced yesterday

READMEChangelog (4)Dependencies (2)Versions (5)Used By (0)

 laravel-wechat-reply
======================

[](#-laravel-wechat-reply-)

 可视化配置微信公众号自动回复规则，自动匹配回复消息。即将支持：可视化页面、匹配自定义处理方法.

[![StyleCI build status](https://camo.githubusercontent.com/7316e19663806109b91c11a020f8f450db187cf723e2ab0384086924f6b8f279/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137393935373736342f736869656c64)](https://camo.githubusercontent.com/7316e19663806109b91c11a020f8f450db187cf723e2ab0384086924f6b8f279/68747470733a2f2f6769746875622e7374796c6563692e696f2f7265706f732f3137393935373736342f736869656c64)

环境要求
----

[](#环境要求)

- PHP &gt;= 7.0

安装
--

[](#安装)

```
$ composer require achais/laravel-wechat-reply -vvv
```

配置
--

[](#配置)

在 config/app.php 中加入我们的 ServiceProvider

```
'providers' => [
    // Application Service Providers...
    Achais\LaravelWechatReply\ServiceProvider::class,
],
```

> 如果你的 laravel &gt;= 5.5 其实可以跳过上面这一步

发布配置文件和静态文件

```
php artisan vendor:publish --provider="Achais\LaravelWechatReply\ServiceProvider"
```

创建数据库表

```
php artisan migrate
```

> 每次执行 migrate 之前最好看一下当前状态, php artisan migrate:status 毕竟数据是无价的

使用
--

[](#使用)

### 自动回复编辑

[](#自动回复编辑)

浏览器访问 /wechat-reply 默认用户名密码是 admin admin
你也可以通过在 .env 文件中添加

```
WECHAT_REPLY_USER=your_username
WECHAT_REPLY_PASSWORD=your_password

```

来自定义登录用户名和密码

### 代码调用

[](#代码调用)

```
use Achais\LaravelWechatReply\Models\WeixinRule;
use Achais\LaravelWechatReply\Models\WeixinReply;
use Achais\LaravelWechatReply\Models\WeixinKeyword;
use Achais\LaravelWechatReply\WechatReply;

// ====== 规则 ======

// 查看全部规则
$rules = WeixinRule::all();

// 创建随机回复一个匹配消息的规则, 名称已存在会报错
$rule = WeixinRule::create(['rule_name' => '规则一', 'reply_mode' => 'random']);

// 创建回复全部匹配消息的规则, 名称已存在会报错
$rule = WeixinRule::create(['rule_name' => '规则二', 'reply_mode' => 'all']);

// 查找或创建规则
$rule = WeixinRule::findOrCreate('规则三', 'random');

// 根据 ID 查找规则
$ruleOne = WeixinRule::findById(1);

// 根据 名称 查找规则, 因为规则中名称唯一所以提供查找功能
$ruleOne = WeixinRule::findByName('规则一');

// ====== 关键词 ======

// 创建一个需要全匹配的关键词, 关联 "规则一"
$keywordOne = WeixinKeyword::create(['keyword' => '关键词一', 'full_match' => true], $ruleOne);

// 创建一个需要半匹配(模糊搜索)的关键词, 关联 "规则一"
$keywordTwo = WeixinKeyword::create(['keyword' => '关键词二', 'full_match' => false], $ruleOne);

// 根据 ID 查找关键词
$keywordTwo = WeixinKeyword::findById(2);

// ====== 回复消息, 更多`消息类型`有待补充 ======

// 创建文本内容的回复消息, 关联 "规则一"
$reply = WeixinReply::create(['type' => 'text', 'content' => '你好'], $ruleOne); // 文字回复, 关联 "规则一"

// 创建图片内容的回复消息, 关联 "规则一"
$reply = WeixinReply::create(['type' => 'image', 'content' => '永久素材 MEDIA_ID'], $ruleOne);

// 创建图文内容的回复消息, 关联 "规则一"
$reply = WeixinReply::create(['type' => 'news', 'content' => '图文内容'], $ruleOne);

// 根据 ID 查找回复消息
$replyOne = WeixinReply::findById(1);

// ====== 关键词匹配功能 ======

// 收到用户消息 "二"
$keyword = '二';

// 你会从 "你好", "图片消息", "图文消息" 中随机收到一个消息, 返回 WechatReply 对象集合
$replies = WechatReply::query($keyword);

/**
Collection {#893 ▼
  #items: array:1 [▼
    0 => WeixinReply {#891 ▶}
  ]
}
*/

// ====== 删除关联关系 ======

// 删除回复、关键词
WeixinKeyword::deleteById(1);
WeixinReply::deleteById(1);

// 删除规则 (关联的回复和关键词也自动删除)
WeixinRule::deleteById(1);
WeixinRule::deleteByName('规则二');
```

Contributing
------------

[](#contributing)

You can contribute in one of three ways:

1. File bug reports using the [issue tracker](https://github.com/achais/laravel-wechat-reply/issues).
2. Answer questions or fix bugs on the [issue tracker](https://github.com/achais/laravel-wechat-reply/issues).
3. Contribute new features or update the wiki.

*The code contribution process is not very formal. You just need to make sure that you follow the PSR-0, PSR-1, and PSR-2 coding guidelines. Any new code contributions must be accompanied by unit tests where applicable.*

License
-------

[](#license)

MIT

###  Health Score

28

—

LowBetter than 54% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 83.3% 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 ~211 days

Total

4

Last Release

1959d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7384071?v=4)[起风](/maintainers/achais)[@achais](https://github.com/achais)

---

Top Contributors

[![achais](https://avatars.githubusercontent.com/u/7384071?v=4)](https://github.com/achais "achais (10 commits)")[![mnizfd](https://avatars.githubusercontent.com/u/24954330?v=4)](https://github.com/mnizfd "mnizfd (2 commits)")

---

Tags

laravelwechatreply

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/achais-laravel-wechat-reply/health.svg)

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

###  Alternatives

[livewire/volt

An elegantly crafted functional API for Laravel Livewire.

4195.3M84](/packages/livewire-volt)[gehrisandro/tailwind-merge-laravel

TailwindMerge for Laravel merges multiple Tailwind CSS classes by automatically resolving conflicts between them

341682.2k18](/packages/gehrisandro-tailwind-merge-laravel)[nickurt/laravel-akismet

Akismet for Laravel 11.x/12.x/13.x

97139.6k2](/packages/nickurt-laravel-akismet)[whitecube/laravel-timezones

Store UTC dates in the database and work with custom timezones in the application.

106106.2k](/packages/whitecube-laravel-timezones)[forxer/laravel-gravatar

A library providing easy gravatar integration in a Laravel project.

4235.6k](/packages/forxer-laravel-gravatar)[chowjiawei/laravel-help-plugin

Integrating useful auxiliary functions into laravel,Assistant tools based on laravel.

671.6k](/packages/chowjiawei-laravel-help-plugin)

PHPackages © 2026

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