feat(ConfigProvider): 添加了 configProvider

This commit is contained in:
李东云
2022-04-26 21:43:00 +08:00
parent 384695efc6
commit 46c07dc232
3 changed files with 193 additions and 1 deletions

View File

@@ -8,6 +8,7 @@
"ergebnis/http-method": "^2.2",
"hyperf/constants": "^2.2",
"hyperf/di": "^2.2",
"hyperf/framework": "^2.2",
"hyperf/http-server": "^2.2",
"hyperf/logger": "^2.2",
"hyperf/translation": "^2.2",

136
composer.lock generated
View File

@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "86323e7c6aa3bc1af7c13eee1f27dba2",
"content-hash": "857f7bd1ec3c2d503b3fc358208b0cd1",
"packages": [
{
"name": "composer/ca-bundle",
@@ -1002,6 +1002,68 @@
],
"time": "2021-12-28T10:07:19+00:00"
},
{
"name": "fig/http-message-util",
"version": "1.1.5",
"source": {
"type": "git",
"url": "https://github.com/php-fig/http-message-util.git",
"reference": "9d94dc0154230ac39e5bf89398b324a86f63f765"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/php-fig/http-message-util/zipball/9d94dc0154230ac39e5bf89398b324a86f63f765",
"reference": "9d94dc0154230ac39e5bf89398b324a86f63f765",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^5.3 || ^7.0 || ^8.0"
},
"suggest": {
"psr/http-message": "The package containing the PSR-7 interfaces"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "1.1.x-dev"
}
},
"autoload": {
"psr-4": {
"Fig\\Http\\Message\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "PHP-FIG",
"homepage": "https://www.php-fig.org/"
}
],
"description": "Utility classes and constants for use with PSR-7 (psr/http-message)",
"keywords": [
"http",
"http-message",
"psr",
"psr-7",
"request",
"response"
],
"support": {
"issues": "https://github.com/php-fig/http-message-util/issues",
"source": "https://github.com/php-fig/http-message-util/tree/1.1.5"
},
"time": "2020-11-24T22:02:12+00:00"
},
{
"name": "graham-campbell/result-type",
"version": "v1.0.4",
@@ -1552,6 +1614,78 @@
},
"time": "2021-07-18T06:50:14+00:00"
},
{
"name": "hyperf/framework",
"version": "v2.2.14",
"source": {
"type": "git",
"url": "https://github.com/hyperf/framework.git",
"reference": "9210ea3e922914813b290b42b2548bf6ff14f537"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hyperf/framework/zipball/9210ea3e922914813b290b42b2548bf6ff14f537",
"reference": "9210ea3e922914813b290b42b2548bf6ff14f537",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"fig/http-message-util": "^1.1.2",
"hyperf/contract": "~2.2.0",
"hyperf/utils": "~2.2.0",
"php": ">=7.2",
"psr/container": "^1.0|^2.0",
"psr/event-dispatcher": "^1.0",
"psr/log": "^1.0|^2.0|^3.0"
},
"suggest": {
"ext-swoole": "Required to use swoole engine.",
"hyperf/command": "Required to use Command annotation.",
"hyperf/di": "Required to use Command annotation.",
"hyperf/dispatcher": "Required to use BootApplication event.",
"symfony/event-dispatcher": "Required to use symfony event dispatcher (^5.0)."
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "2.2-dev"
},
"hyperf": {
"config": "Hyperf\\Framework\\ConfigProvider"
}
},
"autoload": {
"psr-4": {
"Hyperf\\Framework\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A coroutine framework that focuses on hyperspeed and flexible, specifically use for build microservices and middlewares.",
"homepage": "https://hyperf.io",
"keywords": [
"Microservice",
"framework",
"hyperf",
"middleware",
"php",
"swoole"
],
"support": {
"docs": "https://hyperf.wiki",
"issues": "https://github.com/hyperf/hyperf/issues",
"pull-request": "https://github.com/hyperf/hyperf/pulls",
"source": "https://github.com/hyperf/hyperf"
},
"time": "2021-10-28T10:13:44+00:00"
},
{
"name": "hyperf/http-message",
"version": "v2.2.19",

57
src/ConfigProvider.php Normal file
View File

@@ -0,0 +1,57 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://doc.hyperf.io
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace Singularity\HyperfDevelopmentKit;
use Hyperf\Contract\StdoutLoggerInterface;
use Hyperf\Framework\Logger\StdoutLogger;
class ConfigProvider
{
public function __invoke(): array
{
return [
// 合并到 config/autoload/dependencies.php 文件
'dependencies' => [
StdoutLoggerInterface::class => StdoutLogger::class
],
// 合并到 config/autoload/annotations.php 文件
'annotations' => [
'scan' => [
'paths' => [
__DIR__,
],
],
],
// 默认 Command 的定义,合并到 Hyperf\Contract\ConfigInterface 内,换个方式理解也就是与 config/autoload/commands.php 对应
'commands' => [
],
// 与 commands 类似
'listeners' => [],
// 组件默认配置文件,即执行命令后会把 source 的对应的文件复制为 destination 对应的的文件
'publish' => [
[
'id' => 'languages_cn',
'description' => 'The common error message for Chinese',
'source' => __DIR__ . '/../publish/languages/zh_CN/common_error.php',
'destination' => BASE_PATH . '/storage/languages/zh_CN/common_error.php'
],
[
'id' => 'languages_en',
'description' => 'The common error message for English',
'source' => __DIR__ . '/../publish/languages/en/common_error.php',
'destination' => BASE_PATH . '/storage/languages/en/common_error.php'
],
],
];
}
}