API / Minn\Http / Request

Request final readonly class

Minn\Http\Request · public/minn/src/Minn/Http/Request.php · 145 lines

An immutable picture of the incoming request. Built once from the PHP globals at the edge; handlers only ever see this object.

Used by 87 (show)
Admin\AppControllerAdmin\BundleControllerAdmin\EditorControllerAdmin\LanguageControllerAdmin\OverviewControllerAdmin\PackagesControllerAdmin\PreferencesControllerAdmin\RenderControllerAdmin\SessionsControllerAdmin\SiteControllerAdmin\StructureControllerAdmin\SystemControllerAdmin\ThemesControllerAdmin\UpdatesControllerAdmin\V1ControllerAuth\AuthenticatorAuth\SignInAutoloaderContextEngineExtension\SeamsFront\AssetsControllerFront\AttachmentAddressesFront\CanonicalFront\CommentPostControllerFront\FeedControllerFront\FrontControllerFront\ProbeControllerFront\QueryMovesFront\RedirectsFront\ResolverFront\SingleQueriesFront\SitemapControllerEnvelopeKernelRefusalRouterLogin\LoginControllerMedia\UploadOps\DiagnosticsRest\ApiRest\ApplicationPasswordsControllerRest\ArgCheckRest\BatchControllerRest\BlockRendererControllerRest\BlockTypesControllerRest\BlocksControllerRest\CallerRest\CommentsControllerRest\ContextRest\DeclaredPostsControllerRest\DeclaredTermsControllerRest\EmbedRest\ExistingPostRest\GlobalStylesControllerRest\IndexControllerRest\InstalledThemesControllerRest\MediaControllerRest\MenusControllerRest\NavigationControllerRest\PluginsControllerRest\PolicyGateRest\PostsControllerRest\PostsWriteControllerRest\ReplyRest\RevisionsControllerRest\RuntimeEnvelopeRest\RuntimeRoutesRest\SearchControllerRest\ServicesRest\SettingsControllerRest\SidebarsControllerRest\StatusesControllerRest\TemplatesControllerRest\TermsControllerRest\UsersControllerRest\WidgetsControllerRuntime\AjaxControllerRuntime\CommentEventsRuntime\MenuEventsRuntime\PostEventsRuntime\PostSaveRuntime\RuntimeRuntime\TermEventsRuntime\UserEventsTheme\EmbedRendererTheme\FeedHeaders

Constants and properties

propreadonly Minn\Http\Method $method

Promoted from the constructor.

propreadonly string $path

Promoted from the constructor.

propreadonly array $query

Promoted from the constructor.

propreadonly array $headers

Promoted from the constructor.

propreadonly array $cookies

Promoted from the constructor.

propreadonly string $body

Promoted from the constructor.

propreadonly bool $secure

Promoted from the constructor.

propreadonly string $host

Promoted from the constructor.

propreadonly array $form

Promoted from the constructor.

propreadonly array $files

Promoted from the constructor.

propreadonly string $remoteAddress

Promoted from the constructor.

propreadonly array $server

what the server says about itself: software, protocol, and address; diagnostics only

Promoted from the constructor.

Public

new__construct(Minn\Http\Method $method, string $path, array $query, array $headers, array $cookies, string $body, bool $secure, string $host, array $form = array ( ), array $files = array ( ), string $remoteAddress = '', array $server = array ( ))#
$queryarray<string, string|array>
$headersarray<string, string>lower-cased names
$cookiesarray<string, string>
$formarray<string, mixed>decoded form fields, for bodies that are not JSON
$filesarray<string, array>uploaded files, keyed by field
staticfromGlobals(): self#

The request PHP received, read once from the superglobals.

methodjson(): array#

The JSON body as an array, or the form fields when the body is empty or a form.

methodwithPath(string $path): self#

The same request addressed to another path (a REST route carried in ?rest_route=).

methodquery(string $key, ?string $default = NULL): ?string#

One query value as a string, or the default when it is absent or not a string.

methodflag(string $key): bool#

A query value read as the reference reads a boolean argument: true, 1, yes, on; anything else is false.

methodflagged(string $key): bool#

A boolean the query or the body sets, as a DELETE may carry force in either (probes rest-posts-write, rest-terms-controller).

methodhas(string $key): bool#

Whether the query carries this key at all, even empty.

methodheader(string $name): ?string#

A request header by case-insensitive name, or null.

methodcookie(string $name): ?string#

A cookie's value, or null.

methodsegments(): array#

The path split into non-empty segments: "/a/b/" becomes ["a", "b"].

methodqueryStringWithout(string ...$keys): string#

The query string with the given keys removed, ready to append to a redirect.