mirror of
http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore.git
synced 2026-01-15 05:35:09 +08:00
Compare commits
16 Commits
v1.0.0-alp
...
v1.0.0-bet
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e4105a285f | ||
|
|
d20718db32 | ||
|
|
d524fb4e89 | ||
|
|
eeab8a258d | ||
|
|
bac22a8ea6 | ||
|
|
44c26b6491 | ||
|
|
f422fb6b31 | ||
|
|
762acbb368 | ||
|
|
2167fd209a | ||
|
|
fc9b41ef78 | ||
|
|
da518799b3 | ||
|
|
4d8a918898 | ||
|
|
cfbb770559 | ||
|
|
01aa833537 | ||
|
|
c02a08ca6b | ||
|
|
a84b812dd0 |
8
.idea/HDK-Core.iml
generated
8
.idea/HDK-Core.iml
generated
@@ -177,6 +177,14 @@
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/webmozart/assert" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/carbonphp/carbon-doctrine-types" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/symfony/polyfill-php82" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/clue/ndjson-react" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/evenement/evenement" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/react/cache" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/react/child-process" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/react/dns" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/react/event-loop" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/react/socket" />
|
||||
<excludeFolder url="file://$MODULE_DIR$/vendor/react/stream" />
|
||||
</content>
|
||||
<orderEntry type="inheritedJdk" />
|
||||
<orderEntry type="sourceFolder" forTests="false" />
|
||||
|
||||
13
.idea/php.xml
generated
13
.idea/php.xml
generated
@@ -192,12 +192,25 @@
|
||||
<path value="$PROJECT_DIR$/vendor/spatie/pest-plugin-test-time" />
|
||||
<path value="$PROJECT_DIR$/vendor/carbonphp/carbon-doctrine-types" />
|
||||
<path value="$PROJECT_DIR$/vendor/symfony/polyfill-php82" />
|
||||
<path value="$PROJECT_DIR$/vendor/sebastian/resource-operations" />
|
||||
<path value="$PROJECT_DIR$/vendor/facade/ignition-contracts" />
|
||||
<path value="$PROJECT_DIR$/vendor/cooper/hyperf-pest" />
|
||||
<path value="$PROJECT_DIR$/vendor/clue/ndjson-react" />
|
||||
<path value="$PROJECT_DIR$/vendor/evenement/evenement" />
|
||||
<path value="$PROJECT_DIR$/vendor/react/child-process" />
|
||||
<path value="$PROJECT_DIR$/vendor/react/cache" />
|
||||
<path value="$PROJECT_DIR$/vendor/react/dns" />
|
||||
<path value="$PROJECT_DIR$/vendor/react/stream" />
|
||||
<path value="$PROJECT_DIR$/vendor/react/event-loop" />
|
||||
<path value="$PROJECT_DIR$/vendor/react/socket" />
|
||||
</include_path>
|
||||
</component>
|
||||
<component name="PhpProjectSharedConfiguration" php_language_level="8.1" />
|
||||
<component name="PhpStan">
|
||||
<PhpStan_settings>
|
||||
<PhpStanConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpstan" />
|
||||
<PhpStanConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpstan" />
|
||||
<PhpStanConfiguration tool_path="$PROJECT_DIR$/vendor/bin/phpstan" />
|
||||
</PhpStan_settings>
|
||||
</component>
|
||||
<component name="PhpStanOptionsConfiguration">
|
||||
|
||||
3
.idea/phpspec.xml
generated
3
.idea/phpspec.xml
generated
@@ -47,6 +47,9 @@
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
<PhpSpecSuiteConfiguration>
|
||||
<option name="myPath" value="$PROJECT_DIR$" />
|
||||
</PhpSpecSuiteConfiguration>
|
||||
</suites>
|
||||
</component>
|
||||
</project>
|
||||
62
CHANGELOG.md
62
CHANGELOG.md
@@ -1,4 +1,66 @@
|
||||
# 版本更新日志
|
||||
## [1.0.0-beta.4](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-beta.3...v1.0.0-beta.4) (2024-06-23)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **core-middleware:** 修复 JsonResource 不走响应格式化的问题 ([d524fb4](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/d524fb4e890dd06da8c4fe2f0853e34944cd0e28))
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* **composer:** 更新依赖 ([d20718d](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/d20718db32a9dc05535ff66598475186e8016167))
|
||||
|
||||
## [1.0.0-beta.3](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-beta.2...v1.0.0-beta.3) (2024-05-17)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **i18n:** 在没有配置项目默认语言,且传入意料之外的语言时,默认为英文 ([44c26b6](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/44c26b64918702062f28499d566eaa54d8aff491))
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* **composer:** 更新依赖 ([bac22a8](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/bac22a8ea683c42f597e070e1395881b46b2bd83))
|
||||
|
||||
## [1.0.0-beta.2](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-beta.1...v1.0.0-beta.2) (2024-01-18)
|
||||
|
||||
|
||||
### ⚡ Performance Improvements | 性能优化
|
||||
|
||||
* **exception:** 取消了必须是 apifox/postman 的设计 ([2167fd2](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/2167fd209a3cc46ea77fc64909ff8adf71ec6ef0))
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **CoreMiddleware:** 修复如果直接输出 ResponseInterface 实例会报错的问题 ([762acbb](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/762acbb368d6a901478fe3d6b2a3e30793f2c57c))
|
||||
|
||||
## [1.0.0-beta.1](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-beta.0...v1.0.0-beta.1) (2023-12-15)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **bin:** 更新了迁移脚本的目录 ([da51879](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/da518799b3b4301302217af1faa452adbcacf02b))
|
||||
|
||||
## [1.0.0-beta.0](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-alpha.19...v1.0.0-beta.0) (2023-12-15)
|
||||
|
||||
|
||||
### 🐛 Bug Fixes | Bug 修复
|
||||
|
||||
* **bin:** 更新了迁移脚本的目录 ([01aa833](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/01aa8335371fce4f7663eb1c16e4ef7f108e2bc5))
|
||||
|
||||
|
||||
### 📦 Build System | 打包构建
|
||||
|
||||
* **release:** 将版本号改为 beta ([cfbb770](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/cfbb770559e748c77d52e7d913398b1d2a1d8edd))
|
||||
|
||||
## [1.0.0-alpha.19](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-alpha.18...v1.0.0-alpha.19) (2023-12-15)
|
||||
|
||||
|
||||
### ✨ Features | 新功能
|
||||
|
||||
* **bin:** 增加了迁移到最新版本的脚本 ([a84b812](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/commit/a84b812dd0577186379e2df19493cb0fcf9b4fd9))
|
||||
|
||||
## [1.0.0-alpha.18](http://124.126.16.154:8888/singularity/HyperfDevelopmentKitCore/compare/v1.0.0-alpha.17...v1.0.0-alpha.18) (2023-12-14)
|
||||
|
||||
|
||||
|
||||
@@ -1 +1 @@
|
||||
1.0.0-alpha.18
|
||||
1.0.0-beta.4
|
||||
@@ -14,6 +14,9 @@
|
||||
"email": "dongyun.li@luxcreo.ai"
|
||||
}
|
||||
],
|
||||
"bin": [
|
||||
"bin/hdk-migrate-core.sh"
|
||||
],
|
||||
"require": {
|
||||
"php": ">=8.1",
|
||||
"ext-dom": "*",
|
||||
@@ -127,5 +130,5 @@
|
||||
"url": "https://mirrors.aliyun.com/composer/"
|
||||
}
|
||||
},
|
||||
"version": "1.0.0-alpha.18"
|
||||
"version": "1.0.0-beta.4"
|
||||
}
|
||||
|
||||
2531
composer.lock
generated
2531
composer.lock
generated
File diff suppressed because it is too large
Load Diff
@@ -16,12 +16,13 @@ use Rector\Renaming\Rector\Name\RenameClassRector;
|
||||
use Rector\Renaming\ValueObject\MethodCallRename;
|
||||
|
||||
return static function (RectorConfig $rectorConfig): void {
|
||||
defined('BASE_PATH') || define('BASE_PATH', dirname(__DIR__, 3));
|
||||
$rectorConfig->importNames(true, false);
|
||||
|
||||
$rectorConfig->paths([
|
||||
__DIR__ . '/src',
|
||||
__DIR__ . '/publish',
|
||||
__DIR__ . '/tests',
|
||||
BASE_PATH . '/app',
|
||||
BASE_PATH . '/config',
|
||||
BASE_PATH . '/tests',
|
||||
]);
|
||||
|
||||
$rectorConfig
|
||||
|
||||
@@ -2,4 +2,4 @@
|
||||
|
||||
docker run --rm -it \
|
||||
-v $(pwd):/app -e "GIT_AUTHOR_NAME=$(git config user.name)" -e "EMAIL=$(git config user.email)" \
|
||||
detouched/standard-version:latest -p=alpha $1
|
||||
detouched/standard-version:latest -p=beta $1
|
||||
|
||||
@@ -72,10 +72,8 @@ class CommonHandler extends ExceptionHandler
|
||||
$message_name = config('common.response.message_name');
|
||||
$is_testing = config('app_status') === true;
|
||||
$this->request?->url();
|
||||
$is_debug = $this->request?->hasHeader('Postman-Token') || str_starts_with(
|
||||
$this->request?->header('User-Agent', ''),
|
||||
'apifox'
|
||||
);
|
||||
|
||||
$is_debug = $is_testing;
|
||||
$error_type = $throwable::class;
|
||||
$request_time = Carbon::now()->toDateTimeString();
|
||||
$request_data = Json::encode($this->request?->getParsedBody());
|
||||
|
||||
@@ -22,7 +22,7 @@ enum Languages: string
|
||||
return match (mb_strtolower($language)) {
|
||||
'en', 'en_us', 'en-us', 'en-uk', 'en_uk' => self::EN,
|
||||
'zh', 'zh_cn', 'zh-cn' => self::ZH_CN,
|
||||
default => self::from(config('translation.locale')),
|
||||
default => self::from(config('translation.locale') ?? 'en'),
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,6 +18,7 @@ use Hyperf\Di\Annotation\Inject;
|
||||
use Hyperf\HttpMessage\Server\ResponsePlusProxy;
|
||||
use Hyperf\HttpMessage\Stream\SwooleStream;
|
||||
use Hyperf\HttpServer\CoreMiddleware;
|
||||
use Hyperf\Resource\Json\JsonResource;
|
||||
use Lmc\HttpConstants\Header;
|
||||
use Psr\Http\Message\ResponseInterface;
|
||||
use Psr\Http\Message\ServerRequestInterface;
|
||||
@@ -47,14 +48,14 @@ class CommonCoreMiddleware extends CoreMiddleware
|
||||
*/
|
||||
protected function transferToResponse(
|
||||
$response,
|
||||
ServerRequestInterface $request
|
||||
ServerRequestInterface $request,
|
||||
): ResponsePlusInterface {
|
||||
$style = $this->apiStyleService->get();
|
||||
|
||||
if ($style === ApiStyleService::RESTFUL) {
|
||||
$response = $this->transferToRestfulResponse($response, $request);
|
||||
} else {
|
||||
$response = $this->transferToClassicResponse($response, $request);
|
||||
if (!($response instanceof ResponseInterface) || $response instanceof JsonResource) {
|
||||
$response = $style === ApiStyleService::RESTFUL
|
||||
? $this->transferToRestfulResponse($response, $request)
|
||||
: $this->transferToClassicResponse($response, $request);
|
||||
}
|
||||
|
||||
return new ResponsePlusProxy($response);
|
||||
@@ -68,7 +69,7 @@ class CommonCoreMiddleware extends CoreMiddleware
|
||||
*/
|
||||
protected function transferToRestfulResponse(
|
||||
null|array|Arrayable|Jsonable|ResponseInterface|string $response,
|
||||
ServerRequestInterface $request
|
||||
ServerRequestInterface $request,
|
||||
): ResponseInterface {
|
||||
// 分页数据
|
||||
if ($response instanceof LengthAwarePaginatorInterface) {
|
||||
@@ -103,7 +104,7 @@ class CommonCoreMiddleware extends CoreMiddleware
|
||||
*/
|
||||
protected function transferToClassicResponse(
|
||||
null|array|Arrayable|Jsonable|ResponseInterface|string $response,
|
||||
ServerRequestInterface $request
|
||||
ServerRequestInterface $request,
|
||||
): ResponseInterface {
|
||||
$code_name = config('common.response.code_name');
|
||||
$message_name = config('common.response.message_name');
|
||||
@@ -162,6 +163,9 @@ class CommonCoreMiddleware extends CoreMiddleware
|
||||
new SwooleStream(Json::encode($response))
|
||||
);
|
||||
}
|
||||
if ($response instanceof ResponseInterface) {
|
||||
return $response;
|
||||
}
|
||||
// 其他默认按字符串处理
|
||||
return $this->response()->withAddedHeader(Header::CONTENT_TYPE, 'text/plain')->withBody(
|
||||
new SwooleStream((string)$response)
|
||||
|
||||
Reference in New Issue
Block a user