PHPackages                             wechaty/php-wechaty - 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. wechaty/php-wechaty

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

wechaty/php-wechaty
===================

PHP Wechaty is a Conversational AI RPA SDK for Chatbot written in PHP.

v0.0.6(4y ago)6239324[4 issues](https://github.com/wechaty/php-wechaty/issues)Apache-2.0PHPPHP ^7.4 || ^8.0

Since Jul 10Pushed 3y ago4 watchersCompare

[ Source](https://github.com/wechaty/php-wechaty)[ Packagist](https://packagist.org/packages/wechaty/php-wechaty)[ Docs](https://github.com/wechaty/php-wechaty)[ Fund](https://gitee.com/Ride-Group/AmapJava?donate=true)[ Fund](https://paypal.me/zhangchunsheng)[ RSS](/packages/wechaty-php-wechaty/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (3)Dependencies (6)Versions (9)Used By (0)

php-wechaty
===========

[](#php-wechaty)

[![Packagist PHP Version Support](https://camo.githubusercontent.com/700ba2c427eb8436a863daf2daecfa9b9d2f28e96723260f623d66548bac71da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f776563686174792f7068702d77656368617479)](https://packagist.org/packages/wechaty/php-wechaty)[![PHP](https://github.com/wechaty/php-wechaty/workflows/PHP/badge.svg)](https://github.com/wechaty/php-wechaty/actions?query=workflow%3APHP)

[![PHP Wechaty](https://camo.githubusercontent.com/2128480e73a6759c46095a14b9f9b566e549496ae19ce076b7c5cd14ec3d40e6/68747470733a2f2f776563686174792e6769746875622e696f2f7068702d776563686174792f696d616765732f7068702d776563686174792e706e67)](https://github.com/wechaty/php-wechaty)

[![PHP Wechaty Getting Started](https://camo.githubusercontent.com/b4cf3704c0f3cf35bda9a13a479705b7d8af397883f2f8c3f60cbf0074dd42e4/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f504850253230576563686174792d47657474696e67253230537461727465642d376465)](https://github.com/wechaty/php-wechaty-getting-started)[![Wechaty in PHP](https://camo.githubusercontent.com/7293d598c6691af50eb1727ad19e6adb91794e74649892f0f8a7e58483dd4339/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576563686174792d5048502d376465)](https://github.com/wechaty/php-wechaty)

Read code
---------

[](#read-code)

[![](https://camo.githubusercontent.com/6a4edb76a7e92e0faad09a11e42cba7c39803ee6723f8cb1b801f91113d59695/68747470733a2f2f676974706f642e696f2f627574746f6e2f6f70656e2d696e2d676974706f642e737667) ](https://gitpod.io/#https://github.com/wechaty/php-wechaty)

Connecting Chatbots
-------------------

[](#connecting-chatbots)

[![Powered by Wechaty](https://camo.githubusercontent.com/e8d873be065131183baafc9e92a69202e304981259f8c4e8b11e6009848118cc/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f506f776572656425323042792d576563686174792d627269676874677265656e2e737667)](https://github.com/Wechaty/wechaty)

Wechaty is a Conversational SDK for Chatbot Makers that can help you create a bot in 8 lines of PHP

Voice of the Developers
-----------------------

[](#voice-of-the-developers)

> "Wechaty is a great solution, I believe there would be much more users recognize it." [link](https://github.com/Wechaty/wechaty/pull/310#issuecomment-285574472)
> — @Gcaufy, Tencent Engineer, Author of [WePY](https://github.com/Tencent/wepy)
>
> "太好用，好用的想哭"
> — @xinbenlv, Google Engineer, Founder of HaoShiYou.org
>
> "最好的微信开发库" [link](http://weibo.com/3296245513/Ec4iNp9Ld?type=comment)
> — @Jarvis, Baidu Engineer
>
> "Wechaty让运营人员更多的时间思考如何进行活动策划、留存用户，商业变现" [link](http://mp.weixin.qq.com/s/dWHAj8XtiKG-1fIS5Og79g)
> — @lijiarui, Founder &amp; CEO of Juzi.BOT.
>
> "If you know js ... try Wechaty, it's easy to use."
> — @Urinx Uri Lee, Author of [WeixinBot(Python)](https://github.com/Urinx/WeixinBot)

See more at [Wiki:Voice Of Developer](https://github.com/Wechaty/wechaty/wiki/Voice%20Of%20Developer)

Join Us
-------

[](#join-us)

Wechaty is used in many ChatBot projects by thousands of developers. If you want to talk with other developers, just scan the following QR Code in WeChat with secret code *php wechaty*, join our **Wechaty PHP Developers' Home**.

[![Wechaty Friday.BOT QR Code](https://camo.githubusercontent.com/6b9be4147907d218cd7d053ed03aa2836569c349b3c109732e3e77ebbb0ee0a8/68747470733a2f2f776563686174792e6a732e6f72672f696d672f6672696461792d7172636f64652e737667)](https://camo.githubusercontent.com/6b9be4147907d218cd7d053ed03aa2836569c349b3c109732e3e77ebbb0ee0a8/68747470733a2f2f776563686174792e6a732e6f72672f696d672f6672696461792d7172636f64652e737667)

Scan now, because other Wechaty PHP developers want to talk with you too! (secret code: *php wechaty*)

Getting Started
---------------

[](#getting-started)

### 1. Docker

[](#1-docker)

[![Docker Pulls](https://camo.githubusercontent.com/8f08868a024f790ae3eb0c97cf855b956d06b7873c5fbc2735877267025c0d5c/68747470733a2f2f696d672e736869656c64732e696f2f646f636b65722f70756c6c732f706870776563686174792f7068702d77656368617479)](https://hub.docker.com/r/phpwechaty/php-wechaty/)[![Docker Layers](https://camo.githubusercontent.com/6cd6c3a3cfe31ce7d2038709bf552255bfaf4febd803bd2739efbf3867c4d06e/68747470733a2f2f696d616765732e6d6963726f6261646765722e636f6d2f6261646765732f696d6167652f776563686174792f7068702d776563686174792e737667)](https://microbadger.com/#/images/wechaty/php-wechaty)

- PHP Wechaty Starter Repository for Docker -

> PHP Wechaty Docker supports PHP Script.

2.1. Run php script

```
# for php script
docker run -ti --volume="$(pwd)":/bot --rm phpwechaty/php-wechaty:v1 docker/ding-dong-bot.php
```

> Learn more about Wechaty Docker at [Wiki:Docker](https://github.com/Wechaty/php-wechaty/wiki/Docker).

#### New environment variables

[](#new-environment-variables)

1. `WECHATY_PUPPET_SERVICE_TLS_CA_CERT`: can be overwrite by `options.tlsRootCert`. Set Root CA Cert to verify the server or client.

For Puppet Server:

Environment VariableOptionsDescription`WECHATY_PUPPET_SERVICE_TLS_SERVER_CERT``options.tls.serverCert`Server CA Cert (string data)`WECHATY_PUPPET_SERVICE_TLS_SERVER_KEY``options.tls.serverKey`Server CA Key (string data)`WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_SERVER``options.tls.disable`Set `true` to disable server TLSFor Puppet Client:

Environment VariableOptionsDescription`WECHATY_PUPPET_SERVICE_AUTHORITY``options.authority`Service discovery host, default: `api.chatie.io``WECHATY_PUPPET_SERVICE_TLS_CA_CERT``options.caCert`Certification Authority Root Cert, default is using Wechaty Community root cert`WECHATY_PUPPET_SERVICE_TLS_SERVER_NAME``options.serverName`Server Name (mast match for SNI)`WECHATY_PUPPET_SERVICE_NO_TLS_INSECURE_CLIENT``options.tls.disable`Set `true` to disable client TLS> Learn more about tls at

The World's Shortest PHP ChatBot: 8 lines of Code
-------------------------------------------------

[](#the-worlds-shortest-php-chatbot-8-lines-of-code)

### php

[](#php)

```
$wechaty = \IO\Github\Wechaty\Wechaty::getInstance($token, $endPoint);
$wechaty->onScan(function($qrcode, $status, $data) {
    $qr = \IO\Github\Wechaty\Util\QrcodeUtils::getQr($qrcode);
    echo "$qr\n\nOnline Image: https://wechaty.github.io/qrcode/$qrcode\n";
})->onLogin(function(\IO\Github\Wechaty\User\ContactSelf $user) {
})->onMessage(function(\IO\Github\Wechaty\User\Message $message) {
    $message->say("hello from PHP7.4");
})->start();
```

PHP Wechaty Developing Plan
---------------------------

[](#php-wechaty-developing-plan)

We already have Wechaty in TypeScript, It will be not too hard to translate the TypeScript(TS) to PHP because [wechaty](https://github.com/wechaty/wechaty) has only 3,000 lines of the TS code, they are well designed and de-coupled by the [wechaty-puppet](https://github.com/wechaty/wechaty-puppet/) abstraction. So after we have translated those 3,000 lines of TypeScript code, we will almost be done.

As we have already a ecosystem of Wechaty in TypeScript, so we will not have to implement everything in PHP, especially, in the Feb 2020, we have finished the [@chatie/grpc](https://github.com/chatie/grpc) service abstracting module with the [wechaty-puppet-service](https://github.com/wechaty/wechaty-puppet-service) implmentation.

The following diagram shows out that we can reuse almost everything in TypeScript, and what we need to do is only the block located at the top right of the diagram: `Wechaty (PHP)`.

```
  +--------------------------+ +--------------------------+
  |                          | |                          |
  |   Wechaty (TypeScript)   | |      Wechaty (PHP)        |
  |                          | |                          |
  +--------------------------+ +--------------------------+

  +-------------------------------------------------------+
  |                 Wechaty Puppet Service                 |
  |                                                       |
  |                (wechaty-puppet-service)                |
  +-------------------------------------------------------+

+---------------------  @chatie/grpc  ----------------------+

  +-------------------------------------------------------+
  |                Wechaty Puppet Abstract                |
  |                                                       |
  |                   (wechaty-puppet)                    |
  +-------------------------------------------------------+

  +--------------------------+ +--------------------------+
  |      Pad Protocol        | |      Web Protocol        |
  |                          | |                          |
  | wechaty-puppet-padplus   | |(wechaty-puppet-puppeteer)|
  +--------------------------+ +--------------------------+
  +--------------------------+ +--------------------------+
  |    Windows Protocol      | |       Mac Protocol       |
  |                          | |                          |
  | (wechaty-puppet-windows) | | (wechaty-puppet-macpro)  |
  +--------------------------+ +--------------------------+

```

Example: How to Translate TypeScript to PHP
-------------------------------------------

[](#example-how-to-translate-typescript-to-php)

There's a 100 lines class named `Image` in charge of downloading the WeChat image to different sizes.

It is a great example for demonstrating how do we translate the TypeScript to PHP in Wechaty Way:

### Image Class Source Code

[](#image-class-source-code)

- TypeScript:
- PHP:

If you are interested in the translation and want to look at how it works, it will be a good start from reading and comparing those two `Image` class files in TypeScript and PHP at the same time.

To-do List
----------

[](#to-do-list)

- TS: TypeScript
- SLOC: Source Lines Of Code

### Wechaty Internal Modules

[](#wechaty-internal-modules)

1. Class Wechaty
    - TS SLOC(1160):
    - Code
    - Unit Tests
    - Documentation
2. Class Contact
    - TS SLOC(804):
    - Code
    - Unit Tests
    - Documentation
3. Class ContactSelf
    - TS SLOC(199):
    - Code
    - Unit Tests
    - Documentation
4. Class Message
    - TS SLOC(1054):
    - Code
    - Unit Tests
    - Documentation
5. Class Room
    - TS SLOC(1194):
    - Code
    - Unit Tests
    - Documentation
6. Class Image
    - TS SLOC(60):
    - Code
    - Unit Tests
    - Documentation
7. Class Accessory
    - TS SLOC(179):
    - Code
    - Unit Tests
    - Documentation
8. Class Config
    - TS SLOC(187):
    - Code
    - Unit Tests
    - Documentation
9. Class Favorite
    - TS SLOC(52):
    - Code
    - Unit Tests
    - Documentation
10. Class Friendship
    - TS SLOC(417):
    - Code
    - Unit Tests
    - Documentation
11. Class MiniProgram
    - TS SLOC(70):
    - Code
    - Unit Tests
    - Documentation
12. Class RoomInvitation
    - TS SLOC(317):
    - Code
    - Unit Tests
    - Documentation
13. Class Tag
    - TS SLOC(190):
    - Code
    - Unit Tests
    - Documentation
14. Class UrlLink
    - TS SLOC(107):
    - Code
    - Unit Tests
    - Documentation

### Wechaty External Modules

[](#wechaty-external-modules)

1. Class FileBox
    - TS SLOC(638):
    - Code
    - Unit Tests
    - Documentation
2. Class MemoryCard
    - TS SLOC(376):
    - Code
    - Unit Tests
    - Documentation
3. Class WechatyPuppet
    - TS SLOC(1115):
    - Code
    - Unit Tests
    - Documentation
4. Class WechatyPuppetService
    - TS SLOC(909):
    - Code
    - Unit Tests
    - Documentation

Usage
-----

[](#usage)

WIP...

docker
------

[](#docker)

```
docker build -t php-wechaty:v1 .
docker run -ti --volume="$(pwd)":/bot --rm php-wechaty:v1 docker/ding-dong-bot.php
```

Requirements
------------

[](#requirements)

1. PHP 7.4+

Install
-------

[](#install)

### pecl安装

[](#pecl安装)

```
pecl install grpc
pecl install protobuf
pecl install yac
```

### CentOS yum安装

[](#centos-yum安装)

```
# php make sure is 7.4+
sudo yum install php-pecl-grpc
sudo yum install php-pecl-protobuf
sudo yum install php-pecl-yac
sudo yum install php-xml

# php74
sudo yum install php74-php-pecl-grpc
sudo yum install php74-php-pecl-protobuf
sudo yum install php74-php-pecl-yac
sudo yum install php74-php-xml

# php[x]
sudo yum install php[x]-php-pecl-grpc
sudo yum install php[x]-php-pecl-protobuf
sudo yum install php[x]-php-pecl-yac
sudo yum install php[x]-php-xml
```

### Yac enable

[](#yac-enable)

```
yac.enable=1
yac.enable_cli=1
```

### composer

[](#composer)

```
composer config repo.packagist composer https://mirrors.aliyun.com/composer/
# https://packagist.org/packages/wechaty/php-wechaty
composer require wechaty/php-wechaty
```

### test

[](#test)

```
php examples/bot.php
```

Development
-----------

[](#development)

```
```

See Also
--------

[](#see-also)

### PHP for Node.js Developer

[](#php-for-nodejs-developer)

History
-------

[](#history)

### master

[](#master)

### v0.0.1 (Jul 09, 2020)

[](#v001-jul-09-2020)

1. Project created.
2. Welcome our first PHP Wechaty contributor:
    - Chunsheng Zhang （张春生）  ()

Related Projects
----------------

[](#related-projects)

- [Wechaty](https://github.com/wechaty/wechaty) - Conversatioanl AI Chatot SDK for Wechaty Individual Accounts (TypeScript)
- [Python Wechaty](https://github.com/wechaty/python-wechaty) - Python WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Python)
- [Go Wechaty](https://github.com/wechaty/go-wechaty) - Go WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Go)
- [Java Wechaty](https://github.com/wechaty/java-wechaty) - Java WeChaty Conversational AI Chatbot SDK for Wechat Individual Accounts (Java)
- [Scala Wechaty](https://github.com/wechaty/scala-wechaty) - Scala WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (Scala)
- [PHP Wechaty](https://github.com/wechaty/php-wechaty) - PHP WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (PHP)
- [.NET(C#) Wechaty](https://github.com/wechaty/dotnet-wechaty) - .NET(C#) WeChaty Conversational AI Chatbot SDK for WechatyIndividual Accounts (.NET/C#)

Badge
-----

[](#badge)

[![Wechaty in PHP](https://camo.githubusercontent.com/7293d598c6691af50eb1727ad19e6adb91794e74649892f0f8a7e58483dd4339/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f576563686174792d5048502d376465)](https://github.com/wechaty/php-wechaty)

```
[![Wechaty in PHP](https://img.shields.io/badge/Wechaty-PHP-7de)](https://github.com/wechaty/php-wechaty)
```

Contributors
------------

[](#contributors)

[![](https://camo.githubusercontent.com/9300e49054e4b10d3d58b2e8244864d350c9412d324728e13cf3f88d367284b6/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f31)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/1)[![](https://camo.githubusercontent.com/9349ba38b3645cd3b93dbad16174f91e2a8c708707dffeea9d1d59028655e6ca/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f30)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/0)[![](https://camo.githubusercontent.com/e33826a259898f3822e1c1ad6188c98f38f5b68b74b23269de38c791ef766a83/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f32)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/2)[![](https://camo.githubusercontent.com/60540acda45180cdb6e32a83ee806c70e212a94cbb5238e89c9a8a757a05d5b1/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f33)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/3)[![](https://camo.githubusercontent.com/8e00d245dcf12ed537d874b7c3ba149f61ed5c6014be18e7a49d1aecdf934e31/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f34)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/4)[![](https://camo.githubusercontent.com/30534e0fafff676fd48957d01d711f159df4696574b70f9b4ebb049b071dddff/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f35)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/5)[![](https://camo.githubusercontent.com/6a0c0841fc4821f792b96e216d71c2de5ba01b8798da1e172335d736ec34a2e0/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f36)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/6)[![](https://camo.githubusercontent.com/3d0b61325b9339f080e8387c8d7d600987b3aecb69ab80fde2ff36d42d8518ce/68747470733a2f2f736f757263657265722e696f2f66616d652f7a68616e676368756e7368656e672f776563686174792f7068702d776563686174792f696d616765732f37)](https://sourcerer.io/fame/zhangchunsheng/wechaty/php-wechaty/links/7)

1. [@zhangchunsheng](https://github.com/zhangchunsheng) - Chunsheng Zhang (张春生)

Creator
-------

[](#creator)

- [@zhangchunsheng](https://github.com/zhangchunsheng) - Chunsheng Zhang (张春生)

Copyright &amp; License
-----------------------

[](#copyright--license)

- Code &amp; Docs © 2020 Wechaty Contributors
- Code released under the Apache-2.0 License
- Docs released under Creative Commons

###  Health Score

33

—

LowBetter than 75% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity30

Limited adoption so far

Community17

Small or concentrated contributor base

Maturity55

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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 ~95 days

Recently: every ~76 days

Total

6

Last Release

1633d ago

### Community

Maintainers

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

---

Top Contributors

[![zhangchunsheng](https://avatars.githubusercontent.com/u/831839?v=4)](https://github.com/zhangchunsheng "zhangchunsheng (391 commits)")[![huan](https://avatars.githubusercontent.com/u/1361891?v=4)](https://github.com/huan "huan (5 commits)")[![fangmuke](https://avatars.githubusercontent.com/u/26641510?v=4)](https://github.com/fangmuke "fangmuke (2 commits)")

---

Tags

chatbotphpphp74wechatwechatydependencypackageautoload

### Embed Badge

![Health badge](/badges/wechaty-php-wechaty/health.svg)

```
[![Health](https://phpackages.com/badges/wechaty-php-wechaty/health.svg)](https://phpackages.com/packages/wechaty-php-wechaty)
```

###  Alternatives

[composer/composer

Composer helps you declare, manage and install dependencies of PHP projects. It ensures you have the right stack everywhere.

29.4k187.2M2.6k](/packages/composer-composer)[bensampo/laravel-embed

Painless responsive embeds for videos, slideshows and more.

142146.8k](/packages/bensampo-laravel-embed)[shivella/laravel-bitly

Laravel package for generating bitly url

75789.0k1](/packages/shivella-laravel-bitly)[cybercog/laravel-paket

Composer personal web interface. Manage Laravel dependencies without switching to command line!

1753.3k](/packages/cybercog-laravel-paket)[gallib/laravel-short-url

A Laravel package to shorten urls

16516.4k](/packages/gallib-laravel-short-url)

PHPackages © 2026

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