Menu

## AbstractRequest extends AbstractMessage
in package
implements RequestInterface

AbstractRequest.php : 18

Class for managing URLs

##### Tags

see
  https://www.kotchasan.com/

### Interfaces, Classes and Traits

RequestInterface
  Representation of an outgoing, client-side request.

### Table of Contents

$headers : array<string|int, mixed>
$method : string|null
$protocol : string
$requestTarget : string|null
$stream : StreamInterface
$uri : Uri|null
__construct() : mixed
  Initializes the class.
createUriWithGet() : Uri
  Create a class from a link and merge values from $_GET
createUriWithGlobals() : Uri
  Create a class from a link and merge values from $_GET and $_POST
createUriWithPost() : Uri
  Create a class from a link and merge values from $_POST
getBody() : StreamInterface
  Get the body of the message.
getHeader() : array<string|int, string>
  Get the specified header as an array.
getHeaderLine() : string
  Get the specified header as a string.
getHeaders() : array<string|int, mixed>
  Get all the headers.
getMethod() : string
  Get the HTTP method
getProtocolVersion() : string
  Get the protocol version of the message.
getRequestTarget() : string
  Get the request target
getUri() : Uri
  Get the URI
hasHeader() : bool
  Check if a header exists.
map() : mixed
  Merge arrays $_GET and $_POST into a single data array
withAddedHeader() : static
  Add a new header.
withBody() : static
  Set the message body.
withHeader() : static
  Set a header, replacing any existing values.
withHeaders() : static
  Set multiple headers, replacing any existing values.
withMethod() : static
  Set the HTTP method
withoutHeader() : static
  Remove a header.
withProtocolVersion() : static
  Set the protocol version of the message.
withRequestTarget() : static
  Set the request target
withUri() : static
  Set the URI
filterHeader() : mixed
  Check the validity of a header.
getRequestHeaders() : array<string|int, mixed>
  Function to retrieve HTTP headers.

### Properties

#### $headers

AbstractMessage.php : 29
`protected array<string|int, mixed> $headers = []`

The headers of the message.

#### $method

AbstractRequest.php : 23
`protected string|null $method = null`

The HTTP method

#### $protocol

AbstractMessage.php : 34
`protected string $protocol = '1.1'`

The protocol version of the message.

#### $requestTarget

AbstractRequest.php : 28
`protected string|null $requestTarget`

The request target

#### $stream

AbstractMessage.php : 39
`protected StreamInterface $stream`

The body of the message.

#### $uri

AbstractRequest.php : 33
`protected Uri|null $uri`

The URI

### Methods

#### __construct()

AbstractMessage.php : 46

Initializes the class.

`public __construct([bool $withHeader = false ]) : mixed`

##### Parameters

$withHeader : bool = false

  Whether to include the HTTP header or not. Default is false.

##### Return values

mixed —

#### createUriWithGet()

AbstractRequest.php : 43

Create a class from a link and merge values from $_GET

`public static createUriWithGet([string $uri = 'index.php' ][, array<string|int, mixed> $exclude = [] ]) : Uri`

##### Parameters

$uri : string = 'index.php'

  The URI, default is 'index.php'

$exclude : array<string|int, mixed> = []

  An array of keys from $_GET to exclude from the URL

##### Return values

Uri —

#### createUriWithGlobals()

AbstractRequest.php : 61

Create a class from a link and merge values from $_GET and $_POST

`public createUriWithGlobals([string $uri = 'index.php' ][, array<string|int, mixed> $exclude = [] ]) : Uri`

##### Parameters

$uri : string = 'index.php'

  The URI, default is 'index.php'

$exclude : array<string|int, mixed> = []

  An array of keys from $_GET and $_POST to exclude from the URL

##### Return values

Uri —

#### createUriWithPost()

AbstractRequest.php : 80

Create a class from a link and merge values from $_POST

`public static createUriWithPost([string $uri = 'index.php' ][, array<string|int, mixed> $exclude = [] ]) : Uri`

##### Parameters

$uri : string = 'index.php'

  The URI, default is 'index.php'

$exclude : array<string|int, mixed> = []

  An array of keys from $_POST to exclude from the URL

##### Return values

Uri —

#### getBody()

AbstractMessage.php : 58

Get the body of the message.

`public getBody() : StreamInterface`

##### Return values

StreamInterface —

The message body.

#### getHeader()

AbstractMessage.php : 70

Get the specified header as an array.

`public getHeader(string $name) : array<string|int, string>`

##### Parameters

$name : string

  The name of the header.

##### Return values

array<string|int, string> —

The values of the header as an array, or an empty array if not found.

#### getHeaderLine()

AbstractMessage.php : 82

Get the specified header as a string.

`public getHeaderLine(string $name) : string`

##### Parameters

$name : string

  The name of the header.

##### Return values

string —

The concatenated values of the header, separated by commas, or an empty string if not found.

#### getHeaders()

AbstractMessage.php : 93

Get all the headers.

`public getHeaders() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

The headers of the message.

#### getMethod()

AbstractRequest.php : 95

Get the HTTP method

`public getMethod() : string`

##### Return values

string —

The request method

#### getProtocolVersion()

AbstractMessage.php : 103

Get the protocol version of the message.

`public getProtocolVersion() : string`

##### Return values

string —

The protocol version.

#### getRequestTarget()

AbstractRequest.php : 111

Get the request target

`public getRequestTarget() : string`

##### Return values

string —

The request target

#### getUri()

AbstractRequest.php : 124

Get the URI

`public getUri() : Uri`

##### Return values

Uri —

#### hasHeader()

AbstractMessage.php : 115

Check if a header exists.

`public hasHeader(string $name) : bool`

##### Parameters

$name : string

  The name of the header.

##### Return values

bool —

True if the header exists, false otherwise.

#### map()

AbstractRequest.php : 139

Merge arrays $_GET and $_POST into a single data array

`public static map(array<string|int, mixed> &$result, array<string|int, mixed> $array[, array<string|int, mixed> $exclude = [] ]) : mixed`

##### Parameters

$result : array<string|int, mixed>

  A variable to store the result for further use

$array : array<string|int, mixed>

  The array to merge, e.g., $_GET or $_POST

$exclude : array<string|int, mixed> = []

  A list of keys from the array that should not be included in the result

##### Return values

mixed —

#### withAddedHeader()

AbstractMessage.php : 130

Add a new header.

`public withAddedHeader(string $name, string|array<string|int, string> $value) : static`

##### Parameters

$name : string

  The name of the header.

$value : string|array<string|int, string>

  The value(s) of the header as a string or an array of strings.

##### Tags

throws
  InvalidArgumentException

  If the header name is invalid.

##### Return values

static —

#### withBody()

AbstractMessage.php : 151

Set the message body.

`public withBody(StreamInterface $body) : static`

##### Parameters

$body : StreamInterface

  The message body.

##### Return values

static —

#### withHeader()

AbstractMessage.php : 168

Set a header, replacing any existing values.

`public withHeader(string $name, string|array<string|int, string> $value) : static`

##### Parameters

$name : string

  The name of the header.

$value : string|array<string|int, string>

  The value(s) of the header as a string or an array of strings.

##### Tags

throws
  InvalidArgumentException

  for invalid header names or values.

##### Return values

static —

#### withHeaders()

AbstractMessage.php : 185

Set multiple headers, replacing any existing values.

`public withHeaders(array<string|int, mixed> $headers) : static`

##### Parameters

$headers : array<string|int, mixed>

  An array of headers in the format: array($key => $value, $key => $value...)

##### Tags

throws
  InvalidArgumentException

  for invalid header names or values.

##### Return values

static —

#### withMethod()

AbstractRequest.php : 161

Set the HTTP method

`public withMethod(string $method) : static`

##### Parameters

$method : string

  The HTTP method

##### Return values

static —

#### withoutHeader()

AbstractMessage.php : 216

Remove a header.

`public withoutHeader(string $name) : static`

##### Parameters

$name : string

  The name of the header to remove.

##### Return values

static —

#### withProtocolVersion()

AbstractMessage.php : 202

Set the protocol version of the message.

`public withProtocolVersion(string $version) : static`

##### Parameters

$version : string

  The protocol version (e.g., 1.1, 1.0).

##### Return values

static —

#### withRequestTarget()

AbstractRequest.php : 175

Set the request target

`public withRequestTarget(mixed $requestTarget) : static`

##### Parameters

$requestTarget : mixed

  The request target

##### Return values

static —

#### withUri()

AbstractRequest.php : 190

Set the URI

`public withUri(UriInterface $uri[, bool $preserveHost = false ]) : static`

##### Parameters

$uri : UriInterface

  The URI

$preserveHost : bool = false

  Whether to preserve the host header

##### Return values

static —

#### filterHeader()

AbstractMessage.php : 230

Check the validity of a header.

`protected filterHeader(string $name) : mixed`

##### Parameters

$name : string

  The name of the header.

##### Tags

throws
  InvalidArgumentException

  If the header is invalid.

##### Return values

mixed —

#### getRequestHeaders()

AbstractMessage.php : 242

Function to retrieve HTTP headers.

`protected getRequestHeaders() : array<string|int, mixed>`

##### Return values

array<string|int, mixed> —

An array of HTTP headers.

## Search results