config
This commit is contained in:
parent
783563a516
commit
e902d1f4a0
20
README.md
20
README.md
|
@ -1,6 +1,5 @@
|
|||
# Auth 系统 PHP Client
|
||||
|
||||
## 如何使用
|
||||
|
||||
> 该项目使用 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);
|
||||
```
|
||||
|
||||
### 配置
|
||||
|
||||
|
|
|
@ -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()
|
||||
{
|
||||
$this->app->singleton('pd.auth', function () {
|
||||
|
|
7
src/config/pdauth.php
Normal file
7
src/config/pdauth.php
Normal 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'),
|
||||
];
|
Loading…
Reference in New Issue
Block a user