Guide · Open source
How to use EasyWeChat: install with Composer and build a WeChat server
Updated · written with AI from the project's own documentation and checked against our catalogue data
EasyWeChat is an open-source PHP SDK that wraps WeChat's developer APIs so your PHP code can work with WeChat features without building raw API requests by hand. This guide is for PHP developers who want to install it and run the official account server example from its README. By the end you will know the requirements, the install command, and what the basic example does.
Quick start
- 1Confirm PHP and Composer versions. Make sure PHP is 8.0.2 or newer and Composer is 2.0 or newer.
- 2Install the package. Run composer require w7corp/easywechat in your project directory.
- 3Prepare your WeChat credentials. Gather your official account app_id, secret, aes_key and token.
- 4Create the Application. Pass your config array to new Application from the EasyWeChat\OfficialAccount namespace.
- 5Set the server reply. Call getServer(), then use with() to define the reply, as in the README example.
- 6Serve the response. Call serve() and return its response from your endpoint.
Check the requirements before you install
EasyWeChat is a PHP library, so it only works in PHP projects. The README requires PHP 8.0.2 or newer and Composer 2.0 or newer.
- PHP >= 8.0.2
- Composer >= 2.0
Install EasyWeChat with Composer
Install the package into your project with Composer, the PHP package manager. Run the command from your project directory.
composer require w7corp/easywechatRun the official account server example
The README's basic example sets up an official account server. It creates an Application from a configuration array holding your app_id, secret, aes_key and token, then gets the server object and returns a reply through the with method.
When the server serves a request, it sends back the reply text. Replace the placeholder values in the config with your own WeChat official account credentials before running it.
- app_id and secret identify your official account.
- aes_key and token are used for message handling in the example.
- getServer() returns the server, with() sets the reply, and serve() produces the response.
<?php
use EasyWeChat\OfficialAccount\Application;
$config = [
'app_id' => 'wx3cf0f39249eb0exxx',
'secret' => 'f1c242f4f28f735d4687abb469072xxx',
'aes_key' => 'abcdefghijklmnopqrstuvwxyz0123456789ABCDEFG',
'token' => 'easywechat',
];
$app = new Application($config);
$server = $app->getServer();
$server->with(fn() => "您好!EasyWeChat!");
$response = $server->serve();Know what the README covers and what to verify
The README's example covers only the official account server. If your project needs other WeChat features, check the official documentation at easywechat.com first, because the README does not list them.
The README links to a discussions board on GitHub for questions and to the project's security policy for update information.
- Official site and docs: https://easywechat.com
- Discussions: https://github.com/w7corp/easywechat/discussions
- Security and update policy: https://github.com/w7corp/easywechat/security/policy
What people use it for
- Replying automatically to incoming messages on a WeChat official account.
- Adding WeChat messaging to an existing PHP web application.
- Building a PHP backend that uses a packaged SDK instead of writing WeChat API calls by hand.
Frequently asked questions
What do I need to use EasyWeChat?
You need PHP 8.0.2 or newer and Composer 2.0 or newer, according to the README. The library is written for PHP, so it cannot be used directly in projects in other languages.
How do I install EasyWeChat?
Run composer require w7corp/easywechat in your project directory. This is the install command given in the README.
Is EasyWeChat free to use?
The repository is licensed under the MIT License, as stated in the README. Check the license file in the repository for the full terms.
Can EasyWeChat do everything the WeChat API offers?
The README only shows an official account server example. For features beyond that, verify support in the official documentation at easywechat.com before you build on it.
What are the alternatives to EasyWeChat?
Projects listed as comparable are overtrue/wechat for WeChat development and yansongda/pay for payments. Compare their features against your needs before choosing.
Why does my EasyWeChat server not respond?
The README does not include a troubleshooting guide. Check that your PHP and Composer versions meet the requirements, that your config values match your WeChat official account, and ask questions in the project's GitHub discussions.
New agent skills, repos and AI tools — every week
The best new skills and open-source projects, the fastest-growing repos, and one free prompt. Five minutes to read. Unsubscribe anytime.
Our verdict
EasyWeChat suits PHP developers who are building WeChat official account backends or adding WeChat messaging to a PHP application and want a packaged SDK. It is not a ready-made app and does not work outside PHP, so non-PHP teams or people wanting a finished product should look elsewhere.
Install options & downloads