Download the PHP package tuuz/input without Composer

On this page you can find all versions of the php package tuuz/input. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package input

tuuz/input

ThinkPHP 8.1+ 参数校验与 JSON 响应一体化组件包。

要求 PHP 8.5 及以上。


安装

ThinkPHP 8 会通过 extra.think.aliases 自动注册门面别名 InputRet,无需额外配置即可在全局直接使用。

可选依赖(启用高级 XSS 清洗):


Input:参数提取(Input::)

所有 Post* / Get* 方法签名相同:

方法 返回类型 说明
Input::Post($name, $must, $xss) string POST 字符串
Input::PostInt($name, $must) int POST 整数
Input::PostFloat($name, $must) float POST 浮点数
Input::PostBool($name, $must) bool POST 布尔
Input::PostDateTime($name, $must) string\|null RFC3339 格式时间
Input::PostJson($name, $must) array JSON 字符串 → 数组
Input::Get($name, $must, $xss) string GET 字符串
Input::GetInt($name, $must) int GET 整数
Input::GetFloat($name, $must) float GET 浮点数
Input::GetBool($name, $must) bool GET 布尔
Input::GetDateTime($name, $must) string\|null RFC3339 格式时间
Input::GetJson($name, $must) array JSON 字符串 → 数组
Input::Combi($name, $must, $xss) string POST 优先,其次 GET
Input::Raw() string 原始 php://input

Post/Get/Combi 的第三个参数 $xss = true 会对值调用 strip_tags 做基础 XSS 过滤。

示例:

替换默认失败响应类

Input 默认使用包内的 Ret::Fail。若需改用项目自定义响应类:

目标类需具备静态方法 Fail(int $code, mixed $data, string $msg): void


Ret:JSON 响应(Ret::)

基础

输出格式统一:

HTTP 快捷方法

方法 默认 code 默认 echo
Ret::Ok($data, $echo) 0 成功
Ret::BadRequest($echo, $data) 400 参数错误
Ret::Unauthorized($echo, $data) 401 鉴权失败
Ret::Forbidden($echo, $data) 403 权限不足
Ret::NotFound($echo, $data) 404 未找到数据
Ret::ServerError($echo, $data) 500 数据库错误
Ret::Error($code, $echo, $data) 任意 失败

内置 code → 默认提示词对照表

code 文案
0 成功
-1 登录失效请重新登录
400 参数错误
401 鉴权失败
403 权限不足
404 未找到数据
406 / 407 数据不符合期待
500 数据库错误
其他 失败

运行时配置

纯构造(不 exit / 不 echo)


removeXSS() 助手函数


CommitMessage\Analyzer:提交信息解析与描述生成

基于 Conventional Commits 规范。

基础 API

方法 说明
$a->isValid() 是否符合规范
$a->getType() feat / fix / ...
$a->getTypeDescription() 类型英文描述
$a->getScope() input 或 null
$a->isBreakingChange() 是否破坏性变更(header ! 或 footer BREAKING CHANGE
$a->getSubject() 主语
$a->getBody() 正文
$a->getFooter() 页脚
$a->getErrors() 校验错误数组
$a->getMessage() 原始消息
$a->toArray() 数组导出
$a->generateDescription() 生成带 Markdown 格式的人类可读描述
$a->getBumpLevel() SemVer 升级级别:major / minor / patch,无法判断返回 null

generateDescription() 示例输出

SemVer 升级级别判定

条件 级别
! 或 footer BREAKING CHANGE major
type === feat minor
type === fixtype === perf patch
其他类型 null

支持的提交类型

type description
feat A new feature
fix A bug fix
docs Documentation only changes
style Changes that do not affect the meaning of the code
refactor A code change that neither fixes a bug nor adds a feature
perf A code change that improves performance
test Adding missing tests or correcting existing tests
chore Changes to the build process or auxiliary tools
build Changes that affect the build system or external dependencies
ci Changes to CI configuration files and scripts
revert Reverts a previous commit

校验规则


命名空间类名对照

用途 推荐调用方式 完全限定名(FQSEN)
门面 Input Input::xxx() Tuuz\Input\Facade\Input
门面 Ret Ret::xxx() Tuuz\Input\Facade\Ret
核心 Input use Tuuz\Input\Input Tuuz\Input\Input
核心 Ret use Tuuz\Input\Ret Tuuz\Input\Ret
提交解析器 use Tuuz\Input\CommitMessage\Analyzer Tuuz\Input\CommitMessage\Analyzer
XSS 助手 全局函数 removeXSS()Tuuz\Input\Helper\functions.php

License

MIT


All versions of input with dependencies

PHP Build Version
Package Version
Requires php Version >=8.5
topthink/framework Version ^8.1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package tuuz/input contains the following files

Loading the files please wait ...