Request class handles both incoming HTTP requests and outgoing cURL requests. It provides a fluent interface for working with request data, headers, cookies, and validation.
Accessing the request
Access the current request instance:HTTP method information
getMethod()
Get the HTTP method of the current request.Returns the HTTP method (GET, POST, PUT, PATCH, DELETE)
getHttpMethod()
Retrieve the HTTP method from the server.Returns the HTTP method from $_SERVER[‘REQUEST_METHOD’]
URI and URL methods
getURI()
Get the current request URI.Returns the current URI without query string
url()
Set the target URL for outgoing requests.The target URL
Returns Request instance for method chaining
getQuery()
Get the query string from the request.Returns the query string
Domain and subdomain
getDomain()
Get the current domain.Returns the current domain or null
getSubdomain()
Get the current subdomain.Returns the current subdomain or null
Request payload
getPayload()
Retrieve the payload data based on HTTP method.HTTP method to retrieve payload from (defaults to current method)
Returns associative array of payload data
setPayload()
Set the payload data for outgoing requests.Data to set as payload
If true, merges with existing payload
Returns Request instance for method chaining
Headers
getHeaders()
Get all request headers.Returns array of headers
headers()
Set request headers.Associative array of headers
Returns Request instance for method chaining
getHeaderValue()
Get a specific header value by name.Header name (case-insensitive)
Returns header value or null if not found
Cookies
getCookies()
Retrieve all cookies.Returns array of cookies
cookies()
Set cookies for the request.Associative array of cookies
Returns Request instance for method chaining
Validation
validate()
Validate and filter payload against defined rules.Filter rules (same format as filter_var_array)
If true, throws exception on validation failure
Returns filtered and validated payload
validateWith()
Quick validation with predefined rules.Array of field => rule mappings
Returns validated data
validateField()
Validate a single field from the payload.Field name to validate
Filter constant or array with filter options
Returns filtered value or null if validation fails
validationRules()
Get available validation rule patterns.Returns array of predefined validation rules
Filtering data
only()
Get only specific keys from the request.Field name(s) to include
Returns Request instance for method chaining
except()
Get all keys except specified ones.Field name(s) to exclude
Returns Request instance for method chaining
Making outgoing requests
method()
Set the HTTP method for outgoing requests.HTTP method (GET, POST, PUT, PATCH, DELETE)
Returns Request instance for method chaining
ssl()
Enable or disable SSL verification.Enable/disable SSL verification
Returns Request instance for method chaining
send()
Send the cURL request.Returns response data or error message
Utility methods
isJson()
Check if the request content type is JSON.Returns true if Content-Type is application/json