flaksp / 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-fix/fix-enum-return-type
- 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-05-06 12:06:28 UTC
README
去规范化并验证任何类型的用户输入,因此它可以在
- HTML 表单中
- APIs
- 控制台命令参数中
- ... 以及许多其他场景中使用。
安装
警告: 目前库正在实际项目中测试,以检测其设计中可能存在的问题,因此 API 可能会发生变化。请等待稳定版本。
需要 PHP 8.1 或更高版本。该库可在 Packagist 上找到,并可以使用 Composer 安装。
composer require spiks/user-input-processor
特性
库背后的主要原则
- 保持简单。该库仅实现必要的功能子集。易于扩展库以添加更多功能。该库被设计为您的自定义实现的基座,而不是试图做一切的事务瑞士军刀。
- 完全类型覆盖,适用于静态分析工具。公共 API 和库内部遵循最严格的 Psalm 和 PHPStan 规则 - 最受欢迎的 PHP 静态分析工具。我们在设计库时考虑到类型安全性。如果您在项目中使用静态分析,您将非常欣赏这一点。
动机
在我们的内部项目中,我们使用 Symfony 框架,该框架提供了用于用户输入验证的 Symfony Forms 包。Symfony Forms 有很多缺点
- 其内部非常复杂
- 它仅设计用于 HTML 表单,并且不适合 JSON APIs
- 使用静态分析工具与 Symfony Forms 结合使用很痛苦
- 维护包含复杂逻辑的表单很困难
对于用户输入验证,没有很多替代解决方案。这就是我们决定创建自己的原因。
使用
当 API 和设计足够稳定时,本节将被编写。