elim051/yii2-wechat
Composer 安装命令:
composer require elim051/yii2-wechat
包简介
WeChat SDK for yii2, based on overtrue/easywechat
README 文档
README
WeChat SDK for yii2 , based on overtrue/wechat.
This extension helps you access overtrue/wechat application in a simple & familiar way: Yii::$app->wechat.
Installation
composer require elim051/yii2-wechat
或者将下边这个行代码加入到你的composer.json的require中
"elim051/yii2-wechat": "*"
Configuration
Add the SDK as a yii2 application component in the config/main.php:
'components' => [ // ... 'wechat' => [ 'class' => 'elim051\easywechat\Wechat', 'config' => [ // easywechat configurations 'app_id' => 'wx3cf0f39249eb0exx', 'secret' => 'f1c242f4f28f735d4687abb469072axx', // 指定 API 调用返回结果的类型:array(default)/collection/object/raw/自定义类名 'response_type' => 'array', 'log' => [ 'level' => 'debug', 'file' => __DIR__.'/wechat.log', ], ] // 'sessionParam' => '' # wechat user info will be stored in session under this key // 'returnUrlParam' => '' # returnUrl param stored in session ], // ... ]
Usage
// here are two representative examples that will help you: // 微信网页授权: if(Yii::$app->wechat->isWechat && !Yii::$app->wechat->isAuthorized()) { return Yii::$app->wechat->authorizeRequired()->send(); } // 自定义scopes if(Yii::$app->wechat->isWechat && !Yii::$app->wechat->isAuthorized()) { Yii::$app->wechat->scopes = ['snsapi_userinfo']; return Yii::$app->wechat->authorizeRequired()->send(); } // 微信支付(JsApi): $orderData = [ 'openid' => '.. ' // ... etc. ]; $order = new WechatOrder($orderData); $payment = Yii::$app->wechat->payment; $prepayRequest = $payment->prepare($order); if($prepayRequest->return_code = 'SUCCESS' && $prepayRequest->result_code == 'SUCCESS') { $prepayId = $prepayRequest->prepay_id; }else{ throw new yii\base\ErrorException('微信支付异常, 请稍后再试'); } $jsApiConfig = $payment->configForPayment($prepayId); return $this->render('wxpay', [ 'jsApiConfig' => $jsApiConfig, 'orderData' => $orderData ]);
Wechat options configure help docs.
More documentation
see EasyWeChat Docs.
Thanks to overtrue/wechat , realy a easy way to play with wechat SDK 😁.
Thanks to maxwen/yii2-easy-wechat 😁.
elim051/yii2-wechat 适用场景与选型建议
elim051/yii2-wechat 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 8 次下载、GitHub Stars 达 0, 最近一次更新时间为 2018 年 01 月 17 日, 在 PHP 生态内属于活跃度较高的组件。
我们在过去多个企业项目中使用过 elim051/yii2-wechat 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 elim051/yii2-wechat 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
统计信息
- 总下载量: 8
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 9
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-17