Skip to content

Commit 4473ef2

Browse files
committed
Compatibility. overtrue#192
1 parent c3d1b1b commit 4473ef2

File tree

2 files changed

+10
-22
lines changed

2 files changed

+10
-22
lines changed

README.md

Lines changed: 7 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,8 @@ php artisan vendor:publish --provider="Overtrue\LaravelWeChat\ServiceProvider"
5252

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

55+
4. 每个模块基本都支持多账号,默认为 `default`
56+
5557
### Lumen 应用
5658

5759
1.`bootstrap/app.php` 中 82 行左右:
@@ -120,27 +122,6 @@ class WeChatController extends Controller
120122
121123
### 我们有以下方式获取 SDK 的服务实例
122124

123-
##### 使用容器的自动注入
124-
125-
以公众号为例:
126-
127-
```php
128-
<?php
129-
130-
namespace App\Http\Controllers;
131-
132-
use EasyWeChat\OfficialAccount\Application;
133-
134-
class WechatController extends Controller
135-
{
136-
137-
public function demo(Application $officialAccount)
138-
{
139-
// $officialAccount 则为容器中 EasyWeChat\OfficialAccount\Application 的实例
140-
}
141-
}
142-
```
143-
144125
##### 使用外观
145126

146127
```php
@@ -149,9 +130,13 @@ class WechatController extends Controller
149130
$payment = EasyWeChat::payment(); // 微信支付
150131
$openPlatform = EasyWeChat::openPlatform(); // 开放平台
151132
$miniProgram = EasyWeChat::miniProgram(); // 小程序
152-
133+
134+
// 均支持传入配置账号名称
135+
EasyWeChat::officialAccount('foo'); // `foo` 为配置文件中的名称,默认为 `default`
136+
//...
153137
```
154138

139+
155140
## OAuth 中间件
156141

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

src/ServiceProvider.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,9 @@ public function register()
102102
}
103103
$this->app->alias("wechat.{$name}.default", 'wechat.'.$name);
104104
$this->app->alias("wechat.{$name}.default", 'easywechat.'.$name);
105+
106+
$this->app->alias('wechat.'.$name, $class);
107+
$this->app->alias('easywechat.'.$name, $class);
105108
}
106109
}
107110

0 commit comments

Comments
 (0)