Skip to content

Commit 5fc46b9

Browse files
author
sanjingshou
committed
完善readme
1 parent 19dfff0 commit 5fc46b9

File tree

3 files changed

+37
-5
lines changed

3 files changed

+37
-5
lines changed

README.md

Lines changed: 31 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ Laravel5
1111
## 安装
1212

1313
```shell
14-
composer require "overtrue/laravel-wechat:~1.0"
14+
composer require "observer/laravel-pdd:~1.0"
1515
```
1616

1717
## 配置
@@ -40,6 +40,36 @@ php artisan vendor:publish --provider="Observer\LaravelPdd\ServiceProvider"
4040
3. 修改应用根目录下的 `config/pdd.php` 中对应的参数即可。
4141

4242

43+
## 使用
44+
45+
### 我们有以下方式获取 SDK 的服务实例
46+
47+
#### 使用容器的自动注入
48+
49+
```php
50+
<?php
51+
52+
namespace App\Http\Controllers;
53+
54+
use EasyPdd\Foundation\Application;
55+
56+
class PddController extends Controller
57+
{
58+
59+
public function demo(Application $pdd)
60+
{
61+
// $pdd 则为容器中 EasyPdd\Foundation\Application 的实例
62+
}
63+
}
64+
```
65+
66+
#### 使用外观
67+
68+
```php
69+
EasyPdd::oauth;
70+
71+
```
72+
4373
## License
4474

4575
MIT

src/ServiceProvider.php

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
<?php
22
namespace Observer\LaravelPdd;
33

4-
use EasyPdd\Foundation\Application;
4+
use EasyPdd\Foundation\Application as Pdd;
55
use Illuminate\Foundation\Application as LaravelApplication;
66
use Illuminate\Support\ServiceProvider as LaravelServiceProvider;
77

@@ -27,10 +27,12 @@ public function boot()
2727
*/
2828
public function register()
2929
{
30-
$this->app->singleton('easy.pdd', function ($laravelApp) {
31-
$app = new Application(config('pdd'));
30+
$this->app->singleton(Pdd::class, function ($laravelApp) {
31+
$app = new Pdd(config('pdd'));
3232
return $app;
3333
});
3434

35+
$this->app->alias(Pdd::class, 'pdd');
36+
$this->app->alias(Pdd::class, 'easypdd');
3537
}
3638
}

src/config.php

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
'log' => [
66
'level' => env('PDD_LOG_LEVEL', 'debug'),
7-
'file' => env('PDD_LOG_FILE', storage_path('logs/wechat.log')),
7+
'file' => env('PDD_LOG_FILE', storage_path('logs/pdd.log')),
88
],
99

1010
'client_id' => env('PDD_CLIENT_ID', 'your-client_id'), // ClientID

0 commit comments

Comments
 (0)