This commit is contained in:
候学杰 2018-03-19 11:15:37 +08:00
parent 783563a516
commit e902d1f4a0
3 changed files with 39 additions and 1 deletions

View File

@ -1,6 +1,5 @@
# Auth 系统 PHP Client # Auth 系统 PHP Client
## 如何使用
> 该项目使用 composer 来完成加载,需要对项目的 ``` composer.json ``` 中增加如下配置手动制定仓库的地址(因为仓库为公司内部私有的,不对外开放) > 该项目使用 composer 来完成加载,需要对项目的 ``` composer.json ``` 中增加如下配置手动制定仓库的地址(因为仓库为公司内部私有的,不对外开放)
@ -16,5 +15,24 @@
``` ```
执行
```bash
composer require arch/php-auth-client
```
### 代码中启用
注册中间件
```PHP
$app->routeMiddleware([
'auth' => PdAuth\Middleware\Authenticate::class,
]);
```
注册
```PHP
$app->register(PdAuth\PdAuthServiceProvider::class);
```
### 配置

View File

@ -40,6 +40,19 @@ class PdAuthServiceProvider extends ServiceProvider
}); });
} }
protected function setupConfig()
{
$source = realpath(__DIR__ . '/../config.php');
if ($this->app instanceof LaravelApplication && $this->app->runningInConsole()) {
$this->publishes([$source => config_path('pdauth.php')], 'pdauth');
} elseif ($this->app instanceof LumenApplication) {
$this->app->configure('pdauth');
}
$this->mergeConfigFrom($source, 'pdauth');
}
public function register() public function register()
{ {
$this->app->singleton('pd.auth', function () { $this->app->singleton('pd.auth', function () {

7
src/config/pdauth.php Normal file
View File

@ -0,0 +1,7 @@
<?php
return [
'appid' => env('PDAUTH_APP_ID', '100002'),
'secret' => env('PDAUTH_SECRET', '123456'),
'host' => env('PDAUTH_HOST', 'http://auth.dev.haowumc.com'),
];