orinoco / wechat-bundle
此 Symfony bunble 提供与最新 EasyWeChat 库的集成支持。(https://www.easywechat.com/)
1.0.2
2018-01-29 09:28 UTC
Requires
- overtrue/wechat: ^4.0
This package is auto-updated.
Last update: 2024-09-07 17:54:21 UTC
README
此 Symfony bunble 提供与最新 EasyWeChat 库的集成支持。
这个 Symfony bunble 模块用于将 EasyWeChat 库集成到你的项目中。
使用此 bunle 的好处
你不需要在代码中显式构造 EasyWeChat API 对象,只需在需要的地方注入服务对象并调用即可。
你不需要编写代码“new”那些 EasyWeChat 提供的类,而是在需要的地方直接注入,然后直接使用。
用法
一旦 Bundle 成功加载到你的 Symfony 应用程序中,以下服务对象即可使用:
在 Bundle 成功加载到你的 Symfony 应用程序之后,以下5个服务对象就可以使用了:
- orinoco_wechat.application.official_account
- orinoco_wechat.application.payment
- orinoco_wechat.application.mini_program
- orinoco_wechat.application.open_platform
- orinoco_wechat.application.work
例如:
例如:
// in controller class // 在 controller 类中使用 $this->get('orinoco_wechat.application.payment')
<!-- inject it into other services --> <!-- 注入到需要使用的服务类中 --> <service id="..." class="..." public="true"> <argument>...</argument> <argument type="service" id="orinoco_wechat.application.payment" /> <tag name="..." /> </service>
配置
# app/config/config.yml orinoco_wechat: sandbox: true log: level: debug file: /Users/hailong/dev/zshwag/app/../var/logs/wechat.log applications: official_account: app_id: "%wechat_official_account_app_id%" secret: "%wechat_official_account_secret%" response_type: array payment: app_id: "%wechat_payment_app_id%" mch_id: "%wechat_payment_mch_id%" key: "%wechat_payment_key%" cert_path: "%wechat_cert_path%" key_path: "%wechat_key_path%" notify_url: "%wechat_payment_notify_url%" mini_program: app_id: "%wechat_mini_program_app_id%" secret: "%wechat_mini_program_secret%" open_platform: app_id: "%wechat_open_platform_app_id%" secret: "%wechat_open_platform_secret%" token: "%wechat_open_platform_token%" aes_key: "%wechat_open_platform_aes_key%" work: corp_id: "%wechat_work_corp_id%" agent_id: "%wechat_work_agent_id%" secret: "%wechat_work_secret%" response_type: array
生产环境
当你将应用程序部署到生产环境时,需要将 "sandbox" 设置为 false
,并且可以选择关闭日志文件。
当部署到生产环境的时候,需要把 "sandbox" 设置为 false
,并且可以关闭日志文件。
# app/config/config.yml orinoco_wechat: sandbox: false log: enabled: false # ...
参考
请参阅 EasyWeChat 文档以获取更多详细信息。
具体的用法请参考 EasyWeChat 的文档