Overview

Flight's request object provides a fast, simple, and extensible way to access all HTTP request data in your app. It centralizes everything you need for handling GET, POST, cookies, files, headers, and more—no fuss, no dependencies.

Understanding

The request object in Flight acts as your gateway to all incoming HTTP data. Whether you're building a simple form handler or a complex API, it keeps things predictable and beginner-friendly. Flight wraps PHP's superglobals and server info into a single, easy-to-use interface, so you can focus on your app logic instead of plumbing.

Basic Usage

Accessing the Request Object

How to get the request object in any Flight route or callback.

// Example: Get the request object

Getting Query String Parameters (GET)

How to access query string parameters from the request.

// Example: Get a query string parameter

Getting POST Data

How to access POST data from forms or JSON.

// Example: Get POST data

Accessing Cookies

How to read cookies sent by the client.

// Example: Get a cookie value

Accessing Request Headers

How to read HTTP headers from the request.

// Example: Get a header value

Accessing Request Method

How to check the HTTP method (GET, POST, etc.).

// Example: Get the request method

Accessing Request URLs

How to get the full or base URL of the request.

// Example: Get the request URL

Parsing Query Strings

How to parse a query string into an array.

// Example: Parse a query string

Advanced Usage

Handling JSON Input

How to work with JSON request bodies and access decoded data.

// Example: Handle JSON input

Accessing Raw Request Body

How to get the raw HTTP request body for advanced scenarios.

// Example: Get raw request body

Processing File Uploads

How to handle file uploads, move files, and validate them securely.

// Example: Process file uploads

Accessing Uploaded Files

How to access uploaded files and their metadata.

// Example: Access uploaded files

Proxy IP Handling

How to get the real client IP when behind proxies.

// Example: Handle proxy IPs

Method Override Precedence

How Flight determines the request method, including overrides.

// Example: Method override handling

See Also

Troubleshooting

  • Common issue: Request data not available – Ensure you’re using the correct property (query, data, cookies, files).
  • Common issue: File uploads not working – Check input field names and validate file types/extensions and magic bytes.
  • Security caveat: Always validate and sanitize user input, especially file uploads.
  • Method override caveat: Be aware of override precedence (HTTP_X_HTTP_METHOD_OVERRIDE, _method param).
  • Proxy IP caveat: Understand how Flight scans for proxy IPs and configure your server accordingly.

Changelog

  • 3.12.0: Added file upload helpers (getUploadedFiles, moveTo)
  • X.Y.Z: Placeholder for future changes