Update README.md
This commit is contained in:
parent
33ca037634
commit
1700ac3c87
20
README.md
20
README.md
|
@ -15,15 +15,17 @@ composer require arch/php-internal-api-client
|
|||
#### Server
|
||||
|
||||
* 注册中间件
|
||||
```PHP
|
||||
|
||||
```php
|
||||
$app->routeMiddleware([
|
||||
'internal' => PdInternalApi\Middleware\InternalApi::class,
|
||||
]);
|
||||
|
||||
```
|
||||
* 增加配置文件:```config/internal_api.php```
|
||||
在server数组中为调用方增加 secret。
|
||||
```
|
||||
|
||||
* 增加配置文件:```config/internal_api.php``` , 在server数组中为调用方增加 secret。
|
||||
|
||||
```php
|
||||
<?php
|
||||
return [
|
||||
/**
|
||||
|
@ -38,6 +40,7 @@ return [
|
|||
],
|
||||
];
|
||||
```
|
||||
|
||||
* 在项目 .env 文件中增加如下配置
|
||||
|
||||
```
|
||||
|
@ -45,6 +48,7 @@ INTERNAL_SERVER_{{app name}}_SECRET=323232323
|
|||
```
|
||||
|
||||
* 在路由中启用中间件
|
||||
|
||||
```php
|
||||
$route->group(['middleware'=>'internal'],function()use($router){
|
||||
//这里添加对应路由
|
||||
|
@ -55,12 +59,13 @@ $route->group(['middleware'=>'internal'],function()use($router){
|
|||
#### Client
|
||||
|
||||
* 注册服务
|
||||
|
||||
```PHP
|
||||
$app->register(PdInternalApi\ServiceProvider::class);
|
||||
```
|
||||
* 增加配置文件:```config/internal_api.php```
|
||||
在server数组中为调用方增加 secret。
|
||||
```
|
||||
* 增加配置文件:```config/internal_api.php``` , 在server数组中为调用方增加 secret。
|
||||
|
||||
```php
|
||||
<?php
|
||||
return [
|
||||
/**
|
||||
|
@ -90,6 +95,7 @@ INTERNAL_CLIENT_{app name}_SECRET=sdfsdfsdf
|
|||
```
|
||||
|
||||
* 调用
|
||||
|
||||
```php
|
||||
$api = app('internal.api.{{app name}}')
|
||||
$resp = $api->call('{{URI}}',$params);
|
||||
|
|
Loading…
Reference in New Issue
Block a user