spiks / user-input-processor
任何类型用户输入的解耦器和验证器。
0.10.1
2024-05-06 12:05 UTC
Requires
- php: >= 8.1
- ext-mbstring: *
Requires (Dev)
- friendsofphp/php-cs-fixer: ^3.5
- jetbrains/phpstorm-attributes: ^1.0
- phpstan/phpstan: ^1.4
- phpstan/phpstan-phpunit: ^1.0
- phpstan/phpstan-strict-rules: ^1.1
- phpunit/phpunit: ^9.5
- psalm/plugin-phpunit: ^0.16.1
- vimeo/psalm: ^4.20
- dev-main
- 0.10.1
- 0.10.0
- 0.9.0
- 0.8.0
- 0.7.0
- 0.6.2
- 0.6.1
- 0.6.0
- 0.5.0
- 0.4.2
- 0.4.1
- 0.4.0
- 0.3.1
- 0.3.0
- 0.2.1
- 0.2.0
- 0.1.0
- 0.0.1
- dev-dependabot/composer/phpstan/phpstan-1.10.50
- dev-dependabot/npm_and_yarn/prettier-3.1.1
- dev-dependabot/github_actions/shivammathur/setup-php-2.28.0
- dev-dependabot/composer/phpunit/phpunit-9.6.15
- dev-dependabot/github_actions/wagoid/commitlint-github-action-5.4.4
- dev-dependabot/composer/phpstan/phpstan-strict-rules-1.5.2
- dev-dependabot/github_actions/actions/cache-3.3.2
- dev-dependabot/github_actions/hmarr/auto-approve-action-3.2.1
- dev-dependabot/github_actions/actions/checkout-4
- dev-dependabot/npm_and_yarn/prettier/plugin-xml-3.1.0
- dev-dependabot/composer/psalm/plugin-phpunit-0.18.4
- dev-dependabot/composer/vimeo/psalm-4.30.0
- dev-symfony-bundle
- dev-feature/logger
This package is auto-updated.
Last update: 2024-09-06 12:50:18 UTC
README
解耦和验证任何类型的用户输入,因此它可以在
- HTML 表单中
- API 中
- 控制台命令参数中
- ... 以及许多其他场景中使用。
安装
警告: 目前该库正在实际项目中测试,以检测其设计中的可能问题,因此API可能会发生变化。请等待稳定版本。
需要 PHP 8.1 或更高版本。该库可在 Packagist 上找到,并可通过 Composer 安装
composer require spiks/user-input-processor
特性
库背后的主要原则
- 保持简单。 该库仅实现了所需的功能子集。扩展库以添加更多功能非常简单。该库旨在作为您自己实现的基座,而不是尝试做一切事情的瑞士军刀。
- 为静态分析工具提供全面类型覆盖。 公共API和库内部遵循 Psalm 和 PHPStan 的最严格规则 - 最受欢迎的PHP静态分析工具。我们在设计库时考虑了类型安全。如果您在项目中使用静态分析,您会非常欣赏这一点。
动机
在我们内部项目中,我们使用Symfony框架,该框架提供了用于用户输入验证的 Symfony Forms 包。Symfony Forms有很多缺点
- 其内部非常复杂
- 它仅设计用于HTML表单,且不适用于JSON API
- 使用静态分析工具与Symfony Forms配合使用很痛苦
- 在具有复杂逻辑的表单内维护很困难
对于用户输入验证没有很多替代方案。这就是我们决定创建自己的原因。
用法
当确定API和设计足够稳定时,本节将被编写。