build: 添加 hyperf/validation 依赖并调整开发配置

test
yinxiaolong 1 month ago
parent 4bcb946f2e
commit 89bb559762

@ -51,4 +51,4 @@ RUN composer install --no-dev -o && php bin/hyperf.php
EXPOSE 9501 EXPOSE 9501
ENTRYPOINT ["php", "/opt/www/bin/hyperf.php", "start"] ENTRYPOINT ["composer", "watch"]

@ -0,0 +1,8 @@
<?php
namespace App\Contract;
interface ServiceContract
{
}

@ -1,30 +0,0 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace App\Controller;
use Hyperf\Di\Annotation\Inject;
use Hyperf\HttpServer\Contract\RequestInterface;
use Hyperf\HttpServer\Contract\ResponseInterface;
use Psr\Container\ContainerInterface;
abstract class AbstractController
{
#[Inject]
protected ContainerInterface $container;
#[Inject]
protected RequestInterface $request;
#[Inject]
protected ResponseInterface $response;
}

@ -0,0 +1,28 @@
<?php
namespace App\Controller;
use App\Contract\ServiceContract;
use Hyperf\Di\Annotation\Inject;
use Hyperf\Validation\Contract\ValidatorFactoryInterface;
use Hyperf\Validation\Request\FormRequest;
/**
* @property ServiceContract $service
* @property FormRequest $request
*/
abstract class BaseController
{
#[Inject]
protected ValidatorFactoryInterface $validator;
protected function getService(): ServiceContract
{
return $this->service;
}
protected function getRequest(): FormRequest
{
return $this->request;
}
}

@ -1,27 +0,0 @@
<?php
declare(strict_types=1);
/**
* This file is part of Hyperf.
*
* @link https://www.hyperf.io
* @document https://hyperf.wiki
* @contact group@hyperf.io
* @license https://github.com/hyperf/hyperf/blob/master/LICENSE
*/
namespace App\Controller;
class IndexController extends AbstractController
{
public function index()
{
$user = $this->request->input('user', 'Hyperf');
$method = $this->request->getMethod();
return [
'method' => $method,
'message' => "Hello {$user}.",
];
}
}

@ -29,7 +29,8 @@
"hyperf/memory": "~3.1.0", "hyperf/memory": "~3.1.0",
"hyperf/model-cache": "~3.1.0", "hyperf/model-cache": "~3.1.0",
"hyperf/process": "~3.1.0", "hyperf/process": "~3.1.0",
"hyperf/redis": "~3.1.0" "hyperf/redis": "~3.1.0",
"hyperf/validation": "^3.1"
}, },
"require-dev": { "require-dev": {
"friendsofphp/php-cs-fixer": "^3.0", "friendsofphp/php-cs-fixer": "^3.0",

453
composer.lock generated

@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically" "This file is @generated automatically"
], ],
"content-hash": "ecaacd4dde949506185ea2276bffaa39", "content-hash": "333d342acc428b14e60f274a6eab90d4",
"packages": [ "packages": [
{ {
"name": "96qbhy/hyperf-auth", "name": "96qbhy/hyperf-auth",
@ -348,6 +348,57 @@
"abandoned": true, "abandoned": true,
"time": "2022-05-20T20:06:54+00:00" "time": "2022-05-20T20:06:54+00:00"
}, },
{
"name": "doctrine/deprecations",
"version": "1.1.4",
"source": {
"type": "git",
"url": "https://github.com/doctrine/deprecations.git",
"reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/deprecations/zipball/31610dbb31faa98e6b5447b62340826f54fbc4e9",
"reference": "31610dbb31faa98e6b5447b62340826f54fbc4e9",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9 || ^12",
"phpstan/phpstan": "1.4.10 || 2.0.3",
"phpstan/phpstan-phpunit": "^1.0 || ^2",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.5",
"psr/log": "^1 || ^2 || ^3"
},
"suggest": {
"psr/log": "Allows logging deprecations via PSR-3 logger implementation"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Deprecations\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "A small layer on top of trigger_error(E_USER_DEPRECATED) or PSR-3 logging with options to disable all deprecations or selectively for packages.",
"homepage": "https://www.doctrine-project.org/",
"support": {
"issues": "https://github.com/doctrine/deprecations/issues",
"source": "https://github.com/doctrine/deprecations/tree/1.1.4"
},
"time": "2024-12-07T21:18:45+00:00"
},
{ {
"name": "doctrine/inflector", "name": "doctrine/inflector",
"version": "2.0.10", "version": "2.0.10",
@ -521,6 +572,163 @@
], ],
"time": "2022-12-30T00:15:36+00:00" "time": "2022-12-30T00:15:36+00:00"
}, },
{
"name": "doctrine/lexer",
"version": "2.1.1",
"source": {
"type": "git",
"url": "https://github.com/doctrine/lexer.git",
"reference": "861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/doctrine/lexer/zipball/861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6",
"reference": "861c870e8b75f7c8f69c146c7f89cc1c0f1b49b6",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"doctrine/deprecations": "^1.0",
"php": "^7.1 || ^8.0"
},
"require-dev": {
"doctrine/coding-standard": "^9 || ^12",
"phpstan/phpstan": "^1.3",
"phpunit/phpunit": "^7.5 || ^8.5 || ^9.6",
"psalm/plugin-phpunit": "^0.18.3",
"vimeo/psalm": "^4.11 || ^5.21"
},
"type": "library",
"autoload": {
"psr-4": {
"Doctrine\\Common\\Lexer\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Guilherme Blanco",
"email": "guilhermeblanco@gmail.com"
},
{
"name": "Roman Borschel",
"email": "roman@code-factory.org"
},
{
"name": "Johannes Schmitt",
"email": "schmittjoh@gmail.com"
}
],
"description": "PHP Doctrine Lexer parser library that can be used in Top-Down, Recursive Descent Parsers.",
"homepage": "https://www.doctrine-project.org/projects/lexer.html",
"keywords": [
"annotations",
"docblock",
"lexer",
"parser",
"php"
],
"support": {
"issues": "https://github.com/doctrine/lexer/issues",
"source": "https://github.com/doctrine/lexer/tree/2.1.1"
},
"funding": [
{
"url": "https://www.doctrine-project.org/sponsorship.html",
"type": "custom"
},
{
"url": "https://www.patreon.com/phpdoctrine",
"type": "patreon"
},
{
"url": "https://tidelift.com/funding/github/packagist/doctrine%2Flexer",
"type": "tidelift"
}
],
"time": "2024-02-05T11:35:39+00:00"
},
{
"name": "egulias/email-validator",
"version": "3.2.6",
"source": {
"type": "git",
"url": "https://github.com/egulias/EmailValidator.git",
"reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/egulias/EmailValidator/zipball/e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7",
"reference": "e5997fa97e8790cdae03a9cbd5e78e45e3c7bda7",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"doctrine/lexer": "^1.2|^2",
"php": ">=7.2",
"symfony/polyfill-intl-idn": "^1.15"
},
"require-dev": {
"phpunit/phpunit": "^8.5.8|^9.3.3",
"vimeo/psalm": "^4"
},
"suggest": {
"ext-intl": "PHP Internationalization Libraries are required to use the SpoofChecking validation"
},
"type": "library",
"extra": {
"branch-alias": {
"dev-master": "3.0.x-dev"
}
},
"autoload": {
"psr-4": {
"Egulias\\EmailValidator\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Eduardo Gulias Davis"
}
],
"description": "A library for validating emails against several RFCs",
"homepage": "https://github.com/egulias/EmailValidator",
"keywords": [
"email",
"emailvalidation",
"emailvalidator",
"validation",
"validator"
],
"support": {
"issues": "https://github.com/egulias/EmailValidator/issues",
"source": "https://github.com/egulias/EmailValidator/tree/3.2.6"
},
"funding": [
{
"url": "https://github.com/egulias",
"type": "github"
}
],
"time": "2023-06-01T07:04:22+00:00"
},
{ {
"name": "fig/http-message-util", "name": "fig/http-message-util",
"version": "1.1.5", "version": "1.1.5",
@ -3994,6 +4202,160 @@
], ],
"time": "2025-10-30T01:44:44+00:00" "time": "2025-10-30T01:44:44+00:00"
}, },
{
"name": "hyperf/translation",
"version": "v3.1.63",
"source": {
"type": "git",
"url": "https://github.com/hyperf/translation.git",
"reference": "04e8fc76031f256740f16b46dadac0e4e900b48b"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hyperf/translation/zipball/04e8fc76031f256740f16b46dadac0e4e900b48b",
"reference": "04e8fc76031f256740f16b46dadac0e4e900b48b",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"hyperf/collection": "~3.1.0",
"hyperf/context": "~3.1.0",
"hyperf/contract": "~3.1.0",
"hyperf/macroable": "~3.1.0",
"hyperf/stringable": "~3.1.0",
"hyperf/support": "~3.1.0",
"php": ">=8.1",
"psr/container": "^1.0 || ^2.0"
},
"type": "library",
"extra": {
"hyperf": {
"config": "Hyperf\\Translation\\ConfigProvider"
},
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"files": [
"src/Functions.php"
],
"psr-4": {
"Hyperf\\Translation\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "An independent translation component, forked by illuminate/translation.",
"keywords": [
"hyperf",
"translation"
],
"support": {
"issues": "https://github.com/hyperf/translation/issues",
"source": "https://github.com/hyperf/translation/tree/v3.1.63"
},
"funding": [
{
"url": "https://hyperf.wiki/#/zh-cn/donate",
"type": "custom"
},
{
"url": "https://opencollective.com/hyperf",
"type": "open_collective"
}
],
"time": "2025-10-30T01:44:44+00:00"
},
{
"name": "hyperf/validation",
"version": "v3.1.65",
"source": {
"type": "git",
"url": "https://github.com/hyperf/validation.git",
"reference": "fea3ffbf97e5b1f457b50706ef48741a0d715e0c"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/hyperf/validation/zipball/fea3ffbf97e5b1f457b50706ef48741a0d715e0c",
"reference": "fea3ffbf97e5b1f457b50706ef48741a0d715e0c",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"egulias/email-validator": "^3.0",
"hyperf/collection": "~3.1.0",
"hyperf/conditionable": "~3.1.0",
"hyperf/context": "~3.1.0",
"hyperf/contract": "~3.1.0",
"hyperf/di": "~3.1.0",
"hyperf/framework": "~3.1.0",
"hyperf/macroable": "~3.1.0",
"hyperf/stringable": "~3.1.0",
"hyperf/support": "~3.1.0",
"hyperf/tappable": "~3.1.0",
"hyperf/translation": "~3.1.0",
"nesbot/carbon": "^2.21",
"php": ">=8.1",
"psr/container": "^1.0 || ^2.0",
"psr/event-dispatcher": "^1.0",
"psr/http-message": "^1.0 || ^2.0"
},
"suggest": {
"hyperf/database": "Required if you want to use the database validation rule (~3.1.0).",
"hyperf/http-server": "Required if you want to use the request validation rule (~3.1.0)."
},
"type": "library",
"extra": {
"hyperf": {
"config": "Hyperf\\Validation\\ConfigProvider"
},
"branch-alias": {
"dev-master": "3.1-dev"
}
},
"autoload": {
"psr-4": {
"Hyperf\\Validation\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"description": "hyperf validation",
"keywords": [
"hyperf",
"validation"
],
"support": {
"issues": "https://github.com/hyperf/validation/issues",
"source": "https://github.com/hyperf/validation/tree/v3.1.65"
},
"funding": [
{
"url": "https://hyperf.wiki/#/zh-cn/donate",
"type": "custom"
},
{
"url": "https://opencollective.com/hyperf",
"type": "open_collective"
}
],
"time": "2025-12-01T03:37:59+00:00"
},
{ {
"name": "laminas/laminas-mime", "name": "laminas/laminas-mime",
"version": "2.12.0", "version": "2.12.0",
@ -5707,6 +6069,95 @@
], ],
"time": "2025-06-27T09:58:17+00:00" "time": "2025-06-27T09:58:17+00:00"
}, },
{
"name": "symfony/polyfill-intl-idn",
"version": "v1.32.0",
"source": {
"type": "git",
"url": "https://github.com/symfony/polyfill-intl-idn.git",
"reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/symfony/polyfill-intl-idn/zipball/9614ac4d8061dc257ecc64cba1b140873dce8ad3",
"reference": "9614ac4d8061dc257ecc64cba1b140873dce8ad3",
"shasum": "",
"mirrors": [
{
"url": "https://mirrors.aliyun.com/composer/dists/%package%/%reference%.%type%",
"preferred": true
}
]
},
"require": {
"php": ">=7.2",
"symfony/polyfill-intl-normalizer": "^1.10"
},
"suggest": {
"ext-intl": "For best performance"
},
"type": "library",
"extra": {
"thanks": {
"url": "https://github.com/symfony/polyfill",
"name": "symfony/polyfill"
}
},
"autoload": {
"files": [
"bootstrap.php"
],
"psr-4": {
"Symfony\\Polyfill\\Intl\\Idn\\": ""
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Laurent Bassin",
"email": "laurent@bassin.info"
},
{
"name": "Trevor Rowbotham",
"email": "trevor.rowbotham@pm.me"
},
{
"name": "Symfony Community",
"homepage": "https://symfony.com/contributors"
}
],
"description": "Symfony polyfill for intl's idn_to_ascii and idn_to_utf8 functions",
"homepage": "https://symfony.com",
"keywords": [
"compatibility",
"idn",
"intl",
"polyfill",
"portable",
"shim"
],
"support": {
"source": "https://github.com/symfony/polyfill-intl-idn/tree/v1.32.0"
},
"funding": [
{
"url": "https://symfony.com/sponsor",
"type": "custom"
},
{
"url": "https://github.com/fabpot",
"type": "github"
},
{
"url": "https://tidelift.com/funding/github/packagist/symfony/symfony",
"type": "tidelift"
}
],
"time": "2024-09-10T14:38:51+00:00"
},
{ {
"name": "symfony/polyfill-intl-normalizer", "name": "symfony/polyfill-intl-normalizer",
"version": "v1.32.0", "version": "v1.32.0",

Loading…
Cancel
Save