Download the PHP package veasin/ff-web without Composer

On this page you can find all versions of the php package veasin/ff-web. 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 ff-web

ff-web

ff 的 Web 中间件集合——CORS、CSRF、Gzip、JSON、日志、限流、静态文件服务、认证(Basic/Token/JWT/API Key)。


user($data, $storage) — 用户凭证管理

统一凭证生命周期管理:记录、读取、检测、销毁用户凭证。支持多个独立 storage(default / session / token / jwt)。

容器配置——storage 需注册 #user.{name},包含五个回调:

签名 用途
token fn(): ?string 读取当前请求携带的凭证
read fn(string $token): ?array 用 token 恢复用户数据
check fn(string $token): bool 检测 token 是否有效
write fn(object\|array $user): string 持久化用户数据,返回新 token
destroy fn(string $token): void 销毁凭证

user\session() — Session 凭证 storage

基于 PHP 原生 session 的凭证存储,零外部依赖。token 返回 session_id(),数据存储在 $_SESSION['#user']


user\token($provider, $ttl, $prefix) — Token 凭证 storage

通过 $provider 回调接入 Redis/APCu/DB 等任意存储后端。自动从 Authorization: Bearer 头提取 token,生成 64 位随机 hex token。

参数:


user\jwt($secret, $ttl, $algo) — JWT 凭证 storage

纯 PHP 实现 HS256 JWT,零外部依赖。自动从 Authorization: Bearer 头提取 token,payload 内嵌 user 数据和 exp/iat 声明。

参数:


所有预制中间件返回 callable,直接传入 middleware()hump() 使用:

认证相关

basic(prefix, realm) — HTTP Basic 认证

Authorization: Basic 头提取用户名密码,调用验证器。验证器返回值直接存入 user(可返回用户对象而非 true),支持密码含冒号。

参数:

容器配置:


token(prefix, headerName) — Token 认证

从请求头或 URL 查询参数 ?token= 提取 token,调用验证器。

参数:

容器配置:


jwt(prefix, algo) — JWT 认证

Authorization: Bearer <token> 提取 JWT,HMAC 验证签名后解码 payload。

参数:

容器配置:


apikey(prefix, headerName, queryName) — API Key 认证

从请求头或 URL 查询参数提取 API Key,调用验证器。

参数:

容器配置:


通用中间件

cors(options) — CORS 跨域

为响应添加 CORS 头,OPTIONS 预检请求直接返回空响应。

$options


csrf(verify) — CSRF 防护

容器配置:


error(statusMap) — 异常处理

捕获所有 \Throwable 异常,根据异常类型映射状态码和 HTTP 状态描述(reason phrase)。不输出 body,错误信息通过 output(..., ['message' => ...]) 写入 HTTP 响应头(如 HTTP/1.1 400 Invalid argument)。未匹配的异常返回 500 且状态描述为空。

int 值只设置状态码,HTTP 状态描述为空。[int, string] 中 string 为 i18n 键或模板,支持上下文占位符:{status}{code}{message}{file}{line}。其中 {message} 直接替换为 $e->getMessage(),无需预先注册翻译。

未配置消息时自动回退到 container("#web/error/$code") 查找,存在则过 i18n,不存在则状态描述为空:

参数:


gzip(level) — Gzip 响应压缩

检查客户端 Accept-Encoding: gzip,压缩后内容比原内容小时启用压缩。自动跳过 nullarrayOPTIONS 请求。

参数:


json(pretty) — JSON 格式化

将返回值转为 JSON 输出(Content-Type 由 ff 的 json type handler 自动设置)。

参数:


log(level) — 请求日志

记录请求方法、URI、状态码、耗时(ms)、内存(KB)。

参数:

容器配置:


rate(maxRequests, windowSeconds, key) — 接口限流

基于滑动窗口的 IP + 路由级别限流,默认使用 APCu 存储。

参数:

容器配置:


serve(root, cache) — 静态文件服务

根据 URI 在指定目录查找静态文件,自动设置 MIME 类型。目录自动追加 index.html

参数:

优先级:显式传参 > container('#web/static/cache') > 默认无缓存

内置 MIME 类型支持:htmlhtmtxtcssjsjsonpngjpgjpeggifsvgicowoffwoff2ttfzipxml

容器配置:


All versions of ff-web with dependencies

PHP Build Version
Package Version
Requires php Version >=8.4
ext-fileinfo Version *
veasin/ff Version >=0.3.8
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 veasin/ff-web contains the following files

Loading the files please wait ...