API / Minn\Http / Request

Request final readonly class

Minn\Http\Request · public/minn/src/Minn/Http/Request.php · 221 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 114 (show)
Admin\AppControllerAdmin\BundleControllerAdmin\EditorControllerAdmin\LanguageControllerAdmin\LegacyPackControllerAdmin\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\MediaModalMedia\UploadOps\DiagnosticsRest\ApiRest\ApplicationPasswordsControllerRest\ArgCheckRest\BatchControllerRest\BlockDirectoryControllerRest\BlockEditorControllerRest\BlockRendererControllerRest\BlockTypesControllerRest\BlocksControllerRest\CallerRest\CommentsControllerRest\ContextRest\DeclaredPostsControllerRest\DeclaredTermsControllerRest\EmbedRest\ExistingPostRest\FontCollectionsControllerRest\FontFaceCreationRest\FontFamilyChangeRest\FontFamilyCreationRest\FontSettingsRest\FontWritesControllerRest\FontsControllerRest\GlobalStylesControllerRest\IndexControllerRest\InstalledThemesControllerRest\MediaControllerRest\MenuItemStatusRest\MenuListsRest\MenusControllerRest\NavigationControllerRest\PatternDirectoryControllerRest\PluginsControllerRest\PolicyGateRest\PostsControllerRest\PostsWriteControllerRest\ReplyRest\RevisionCollectionRest\RevisionsControllerRest\RuntimeEnvelopeRest\RuntimeRoutesRest\SearchControllerRest\ServicesRest\SettingsControllerRest\SidebarsControllerRest\SiteHealthControllerRest\StatusesControllerRest\TemplateRevisionsControllerRest\TemplatesControllerRest\TermsControllerRest\UsersControllerRest\WidgetObjectRest\WidgetsControllerRuntime\AdminActionControllerRuntime\AjaxControllerRuntime\ApplicationPasswordRecordsRuntime\CommentChecksRuntime\CommentEventsRuntime\EarlyRequestRuntime\LegacyPackRuntime\MenuEventsRuntime\PostEventsRuntime\PostSaveRuntime\PostTagsRuntime\QueryArgsRuntime\RequestHeadersRuntime\RuntimeRuntime\SiteUrlsRuntime\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
staticserverVariable(string $name): mixed#

A server variable as PHP holds it now, null when unset: it may have changed since the request was read (a proxy plugin marking HTTPS, the WordPress layer filling in REQUEST_URI).

staticrequestVariable(string $name): mixed#

A request variable (query or form) as PHP holds it now, null when unset.

staticqueryVariable(string $name): mixed#

A query variable as PHP holds it now, null when unset: plugin code may have set it since the request was read.

staticcookieVariable(string $name): mixed#

A cookie as PHP holds it now, null when unset: plugin code may have set it since the request was read.

staticwithPostedForm(array $fields, Closure $run): mixed#

Runs plugin code that reads its fields from the posted form (a widget control's update callback) with these fields as $_POST and $_REQUEST; both are as they were after.

$fieldsarray<string, mixed>
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.

methodwithQueryBeneathBody(array $reserved): self#

The same request with its query's arguments read beneath its body's, as the reference's REST request reads a write's parameters: a JSON or form body names an argument first and the query fills in the rest. A raw body (an upload) is left as it came.

$reservedlist<string>query keys that address the request rather than name an argument
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.