Repository navigation
Internals Router Http Request
Framework Internals · Subsystem overview · Developer guide
Source: awt_src/classes/router/http/Request.php · Snapshot 8411f4287706.
Routing separates definition, HTTP request snapshot, matching, method policy, execution and error responses. Collaborators can be replaced through constructor injection.
final class Request implements \router\interface\IRequestSource description (behavioral corrections are recorded in Known discrepancies):
A request snapshot, independent of PHP globals after construction.
Declarations below preserve visibility, type, default and modifiers exactly. A typed property without an initializer remains uninitialized until its constructor or another method assigns it. Mutable fields belong to this instance unless marked static; readonly fields can be initialized once. Constructor-promoted properties are also listed below.
| Member | Declaration | Purpose or source contract |
|---|---|---|
| Constructor-promoted | private readonly array $server = [] |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Constructor-promoted | private readonly array $post = [] |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Constructor-promoted | private readonly string $body = '' |
Initialized from the constructor argument; default expression is evaluated when the argument is omitted. |
| Method | Signature |
|---|---|
| __construct | public function __construct( private readonly array $server = [], private readonly array $post = [], private readonly string $body = '', ) |
| path | public function path(): string |
| method | public function method(): string |
| csrfToken | public function csrfToken(string $name = '_token'): mixed |
public function __construct(
private readonly array $server = [],
private readonly array $post = [],
private readonly string $body = '',
);| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$server |
private readonly array $server = [] |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$post |
private readonly array $post = [] |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
$body |
private readonly string $body = '' |
Operation input; the exact use, validation and propagation are shown in the implementation trace. |
Concrete no-op/default hook: this method performs no work. Override it where the lifecycle or extension contract calls for behavior.
public function path(): stringReturn expressions (including local callbacks): parse_url($this->server['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/'.
Implementation, validation guards and interaction order
public function path(): string
{
return parse_url($this->server['REQUEST_URI'] ?? '/', PHP_URL_PATH) ?: '/';
}public function method(): stringReturn expressions (including local callbacks): strtoupper($override); $method.
Implementation, validation guards and interaction order
public function method(): string
{
$method = strtoupper($this->server['REQUEST_METHOD'] ?? 'GET');
$override = $this->post['_method'] ?? null;
if ($method === 'POST' && is_string($override)
&& in_array(strtoupper($override), ['PUT', 'PATCH', 'DELETE'], true)) {
return strtoupper($override);
}
return $method;
}public function csrfToken(string $name = '_token'): mixed| Parameter | Type, modifiers and default | Purpose |
|---|---|---|
$name |
string $name = '_token' |
Named key/label selected by this API; its exact scope is shown by the implementation trace. |
Return malformed values unchanged so validation can reject them.
Return expressions (including local callbacks): $token.
Implementation, validation guards and interaction order
/** Return malformed values unchanged so validation can reject them. */
public function csrfToken(string $name = '_token'): mixed
{
$token = $this->server['HTTP_X_CSRF_TOKEN'] ?? $this->post[$name] ?? null;
if ($token === null && str_starts_with(strtolower($this->server['CONTENT_TYPE'] ?? ''), 'application/x-www-form-urlencoded')) {
parse_str($this->body, $fields);
$token = $fields[$name] ?? null;
}
return $token;
}AWT Framework Wiki · Home · Installation Guide · Developer Guide · Framework Internals
Philosophy · Architecture · Known discrepancies · Verification
Installation Guide
Developer Guide
- Learning sequence
- First package
- Package structure
- Lifecycle
- Runtimes
- Events and objects
- Routing and controllers
- Views and resources
- Database and models
- Storage and caching
- Configuration and CLI
- Responses and errors
- Extension points
Framework Internals
- Architecture
- Bootstrap
- Packages
- Runtime
- Events and context
- Objects
- HTTP routing and controllers
- Rendering
- Blade integration
- Database
- Models
- Storage and caching
- Settings
- CLI
- Identity and sessions
- Responses
- Errors
- Complete source inventory
Documentation notes