Download the PHP package overtrue/laravel-wechat without Composer

On this page you can find all versions of the php package overtrue/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

EasyWeChat for Laravel

微信 SDK EasyWeChat for Laravel, 基于 w7corp/easywechat

Sponsor me

7.x 起不再默认支持 Lumen。

框架要求

安装

配置

  1. 创建配置文件:

  2. 可选,添加别名

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

使用

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

对于 Laravel 11.x 可以使用bootstrap/app.php 中的$middleware->validateCsrfTokens方法:

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

路由:

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

然后创建控制器 WeChatController

OAuth 中间件

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

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

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

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

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

模拟授权

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

  1. 准备模拟授权资料:

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

  1. 将资料写入 session:

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

事件

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

开放平台支持

您可以适用内置的 Overtrue\LaravelWeChat\Traits\HandleOpenPlatformServerEvents 来快速完成开放平台的服务端验证工作:

routes/web.php:

app/Http/Controllers/OpenPlatformController.php:

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

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

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

:heart: Sponsor me

Sponsor me

如果你喜欢我的项目并想支持它,点击这里 :heart:

Project supported by JetBrains

Many thanks to Jetbrains for kindly providing a license for me to work on this and other open-source projects.

PHP 扩展包开发

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

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

License

MIT


All versions of laravel-wechat with dependencies

PHP Build Version
Package Version
Requires illuminate/container Version ^9.0|^10.0|^11.0
w7corp/easywechat Version ^6.0.0
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 overtrue/laravel-wechat contains the following files

Loading the files please wait ....