Download the PHP package freyo/laravel-entwechat without Composer

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

laravel-entwechat

Build Status Coverage Status Quality Score Packagist Version Total Downloads

微信 SDK for Laravel 5 / Lumen, 基于 freyo/entwechat

本项目仅适用于一个固定企业号,支持一个或多个权限组

安装

  1. 安装包文件

    使用前请禁用 laravel-debugbar

配置

Laravel 应用

  1. 注册 ServiceProvider:

  2. 创建配置文件:

  3. 请修改应用根目录下的 config/entwechat.php 中对应的项即可;

  4. (可选)添加外观到 config/app.php 中的 aliases 部分:

Lumen 应用

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

使用

Laravel <= 5.1

  1. Laravel 5 起默认启用了 CSRF 中间件,因为微信的消息是 POST 过来,所以会触发 CSRF 检查导致无法正确响应消息,所以请去除默认的 CSRF 中间件,改成路由中间件。可以参考:overtrue gist:Kernel.php
  2. 5.1 里的 CSRF 已经带了可忽略部分url的功能,你可以参考:http://laravel.com/docs/master/routing#csrf-protection

Laravel 5.2+

Laravel 5.2 以后的版本默认启用了 web 中间件,意味着 CSRF 会默认打开,有两种方案:

  1. 在 CSRF 中间件里排除微信相关的路由
  2. 关掉 CSRF 中间件(极不推荐)

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

假设您的域名为 example.org 那么请登录微信公众平台企业号 “应用中心” 选择一个应用启用回调模式,并修改 “URL(服务器配置)” 为: http://example.org/wechat

路由:

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

然后创建控制器 WechatController

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

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

使用容器的自动注入
使用外观

config/app.phpalias 部分添加外观别名:

然后就可以在任何地方使用外观方式调用 SDK 对应的服务了:

OAuth 中间件

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

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

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

以 5.2 为例:

如果你在用 5.1 上面没有 'web' 中间件

当然,你也可以在中间件参数指定当前的 account:

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

License

MIT


All versions of laravel-entwechat with dependencies

PHP Build Version
Package Version
Requires freyo/entwechat Version ^1.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 freyo/laravel-entwechat contains the following files

Loading the files please wait ....