kynetcode/wpzylos-http
Composer 安装命令:
composer require kynetcode/wpzylos-http
包简介
HTTP Request, Response and Middleware pipeline for WPZylos framework
README 文档
README
A WordPress-friendly HTTP layer providing clean request capture, sanitized input helpers, structured responses, and a middleware pipeline — all designed to work seamlessly within the WordPress ecosystem.
Namespace: WPZylos\Framework\Http
Features
- Request Capture — Automatically captures
$_GET,$_POST,$_FILES, and$_SERVERwithwp_unslashapplied. - Sanitized Input Helpers — 10 type-safe accessors wrapping WordPress sanitization functions (
sanitize_text_field,sanitize_email,wp_kses_post, etc.). - Structured Responses — Static factories for HTML, JSON, redirects, empty, and error responses.
- Middleware Pipeline — Laravel-inspired pipeline supporting class names, instances, and callables.
- Service Provider — Ready-to-use provider that registers the request as a singleton and the pipeline as a factory.
- Immutable Request — Final class with a clear, predictable API.
Requirements
| Requirement | Version |
|---|---|
| PHP | 8.0+ |
| WordPress | 6.0+ |
Installation
composer require wpzylos/http
Quick Start
Capture a Request
use WPZylos\Framework\Http\Request; $request = Request::capture();
Read Input
// POST first, then GET $name = $request->input('name', 'Guest'); // Sanitized helpers $email = $request->email('email'); $page = $request->absint('page', 1); // Subset of input $credentials = $request->only(['username', 'password']);
Return a Response
use WPZylos\Framework\Http\Response; // JSON response $response = Response::json(['status' => 'ok', 'user' => $name]); $response->send(); // Redirect Response::redirect('/dashboard')->send();
Middleware Pipeline
use WPZylos\Framework\Http\Pipeline; $response = (new Pipeline($container)) ->send($request) ->through([AuthMiddleware::class, LoggingMiddleware::class]) ->then(function (Request $request) { return Response::json(['message' => 'Hello!']); });
Documentation
- Usage Guide — Comprehensive guide covering request capture, input reading, responses, middleware, and the service provider.
- API Reference — Full method-by-method reference for every class and interface.
Support the Project
License
MIT License. See LICENSE for details.
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 4
- 依赖项目数: 1
- 推荐数: 0
其他信息
- 授权协议: GPL-2.0-or-later
- 更新时间: 2026-06-16