kynetcode/wpzylos-http

HTTP Request, Response and Middleware pipeline for WPZylos framework

Maintainers

Package info

github.com/KYNetCode/wpzylos-http

Documentation

pkg:composer/kynetcode/wpzylos-http

Fund package maintenance!

Paypal

Statistics

Installs: 14

Dependents: 1

Suggesters: 0

Stars: 0

Open Issues: 0

v1.0.0 2026-06-16 18:52 UTC

This package is auto-updated.

Last update: 2026-06-16 20:01:13 UTC


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 $_SERVER with wp_unslash applied.
  • 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.