Download the PHP package duan617/laravel-wechat without Composer

On this page you can find all versions of the php package duan617/laravel-wechat. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-wechat

laravel-wechat

当前项目 Clone 自 overtrue/laravel-wechat, 基于原仓库的 5.1.0 版本维护, 并启用新的版本号进行迭代.

微信 SDK for Laravel 5 / Lumen, 基于 overtrue/wechat

交流QQ群:319502940

框架要求

Laravel/Lumen >= 5.1

安装

配置

Laravel 应用

  1. config/app.php 注册 ServiceProvider 和 Facade (Laravel 5.5 + 无需手动注册)

  2. 创建配置文件:

  3. 修改应用根目录下的 config/wechat.php 中对应的参数即可。

  4. 每个模块基本都支持多账号,默认为 default

Lumen 应用

  1. bootstrap/app.php 中 82 行左右:

  2. 如果你习惯使用 config/wechat.php 来配置的话,将 vendor/overtrue/laravel-wechat/src/config.php 拷贝到项目根目录/config目录下,并将文件名改成wechat.php

使用

:rotating_light: 在中间件 App\Http\Middleware\VerifyCsrfToken 排除微信相关的路由,如:

下面以接收普通消息为例写一个例子:

假设您的域名为 overtrue.me 那么请登录微信公众平台 “开发者中心” 修改 “URL(服务器配置)” 为: http://overtrue.me/wechat

路由:

注意:一定是 Route::any, 因为微信服务端认证的时候是 GET, 接收用户消息时是 POST

然后创建控制器 WeChatController

上面例子里的 Log 是 Laravel 组件,所以它的日志不会写到 EasyWeChat 里的,建议把 wechat 的日志配置到 Laravel 同一个日志文件,便于调试。

我们有以下方式获取 SDK 的服务实例

使用外观

OAuth 中间件

使用中间件的情况下 app/config/wechat.php 中的 oauth.callback 就随便填写吧(因为用不着了 :smile:)。

  1. app/Http/Kernel.php 中添加路由中间件:

  2. 在路由中添加中间件:

中间件支持指定配置名称:'wechat.oauth:default',当然,你也可以在中间件参数指定当前的 scopes:

上面的路由定义了 /user 是需要微信授权的,那么在这条路由的回调 或 控制器对应的方法里, 你就可以从 session('wechat.oauth_user.default') 拿到已经授权的用户信息了。

模拟授权

有时候我们希望在本地开发完成后线上才真实的走微信授权流程,这将减少我们的开发成本,那么你需要做以下两步:

  1. 准备假资料:

以下字段在 scope 为 snsapi_userinfo 时尽可能配置齐全哦,当然,如果你的模式只是 snsapi_base 的话只需要 openid 就好了。

  1. 将资料写入 session:

注意:一定要在 OAuth 中间件之前写入,比如你可以创建一个全局中间件来完成这件事儿,当然了,只在开发环境启用即可。

事件

你可以监听相应的事件,并对事件发生后执行相应的操作。

开放平台路由支持

在配置文件 route 处取消注释即可启用。

Tips: 默认的控制器会根据微信开放平台的推送内容触发如下事件,你可以监听相应的事件并进行处理:

配置后 http://example.com/open-platform/serve 则为开放平台第三方应用设置的授权事件接收 URL。

更多 SDK 的具体使用请参考:https://easywechat.com

PHP 扩展包开发

想知道如何从零开始构建 PHP 扩展包?

请关注我的实战课程,我会在此课程中分享一些扩展开发经验 —— 《PHP 扩展包实战教程 - 从入门到发布》

License

MIT


All versions of laravel-wechat with dependencies

PHP Build Version
Package Version
Requires illuminate/container Version ^5.1 || ^6.0 || ^7.0 || ^8.0
duan617/easywechat Version ^1.2.3
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package duan617/laravel-wechat contains the following files

Loading the files please wait ....