topphp/topphp-wechat

基于easywechat的微信组件

v1.0.1 2020-09-24 06:11 UTC

This package is auto-updated.

Last update: 2024-04-24 14:37:34 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

基于easywechat封装的一个组件.使用方法和原始功能几乎一模一样,只是增加了swoole环境下的支持.加入了容器注入,在整个生命周期内为单例.

使用教程

1.入门

我们知道,使用easywechat时要先初始化,像这样:

$config = [
    'app_id' => 'wx3cf0f39249eb0exx',
    'secret' => 'f1c242f4f28f735d4687abb469072axx',
];
$app = Factory::officialAccount($config);

而在topphp中,已经进行了容器注入,所以在实例化时要这样写:

$wechat = $this->app->get(WeChat::class);
$config = $this->app->config->get('wechat');
$app = $wechat::officialAccount($config);

# 也可以这样用
$app = WeChat::officialAccount($config);
# 但是要注意,这样是多例模式
2.组件安装后会在骨架工程的config 目录自动生成wechat.php文件,里面则是 easywechat 的配置参数

版本

现代的PHP组件都使用语义版本方案(http://semver.org), 版本号由三个点(.)分数字组成(例如:1.13.2).第一个数字是主版本号,如果PHP组件更新破坏了向后兼容性,会提升主版本号. 第二个数字是次版本号,如果PHP组件小幅更新了功能,而且没有破坏向后兼容性,会提升次版本号. 第三个数字(即最后一个数字)是修订版本号,如果PHP组件修正了向后兼容的缺陷,会提升修订版本号.

Structure

组件结构

bin/        
build/
docs/
config/
src/
tests/
vendor/

Install

Via Composer

$ composer require topphp/topphp-wechat

Change log

Please see CHANGELOG for more information on what has changed recently.

Testing

$ composer test

Contributing

Please see CONTRIBUTING and CODE_OF_CONDUCT for details.

Security

If you discover any security related issues, please email sleep@kaituocn.com instead of using the issue tracker.

Credits

License

The MIT License (MIT). Please see License File for more information.