Skip to content

Commit

Permalink
Phar 打包器
Browse files Browse the repository at this point in the history
  • Loading branch information
tw2066 committed Sep 5, 2024
1 parent 3c21ac8 commit ce8db8e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 2 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -534,6 +534,10 @@ return [
];
```

## Phar 打包器

> 使用 Phar 打包器时, 可以`api_docs.php``scan_cacheable`配置设置为false, 生成代理类后, 再设置true进行打包
## Swagger界面

![hMvJnQ](https://gitee.com/tw666/source/raw/master/img/swagger.png)
Expand Down
7 changes: 7 additions & 0 deletions publish/api_docs.php
Original file line number Diff line number Diff line change
Expand Up @@ -99,6 +99,13 @@
['response' => 500, 'description' => 'System error'],
],

/*
|--------------------------------------------------------------------------
| 使用 Phar 打包器时, 可以先设置false, 生成代理类后, 再设置true进行打包
|--------------------------------------------------------------------------
*/
// 'scan_cacheable' => true,

/*
|--------------------------------------------------------------------------
| swagger 的基础配置
Expand Down
9 changes: 7 additions & 2 deletions src/Listener/AfterDtoStartListener.php
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
use Hyperf\ApiDocs\Swagger\SwaggerOpenApi;
use Hyperf\ApiDocs\Swagger\SwaggerPaths;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\DTO\DtoConfig;
use Hyperf\DTO\Event\AfterDtoStart;
use Hyperf\Event\Contract\ListenerInterface;
use Hyperf\HttpServer\Router\Handler;
Expand All @@ -24,8 +25,8 @@ public function __construct(
private SwaggerOpenApi $swaggerOpenApi,
private SwaggerComponents $swaggerComponents,
private SwaggerConfig $swaggerConfig,
) {
}
private DtoConfig $dtoConfig,
) {}

public function listen(): array
{
Expand All @@ -48,6 +49,10 @@ public function process(object $event): void
if (! $this->swaggerConfig->getOutputDir()) {
return;
}
dump($this->dtoConfig->isScanCacheable());
if ($this->dtoConfig->isScanCacheable()) {
return;
}

$this->swaggerOpenApi->init();
/** @var SwaggerPaths $swagger */
Expand Down

0 comments on commit ce8db8e

Please sign in to comment.