getBodyParam.php
Table of Contents
Functions
- getBodyParam() : mixed
- Retrieves a single parameter from the HTTP request body.
Functions
getBodyParam()
Retrieves a single parameter from the HTTP request body.
getBodyParam(ServerRequestInterface|null $request, string $name) : mixed
This helper extracts a value from the parsed request body ($request->getParsedBody()),
supporting dot notation for nested structures (e.g. 'user.address.city').
The body is internally normalized into a fully associative array using toAssociativeArray(), ensuring compatibility with both array and stdClass-based JSON payloads.
It internally uses hasKeyValue() and getKeyValue() from the oihana\core\accessors namespace.
If the request is null, or if the specified parameter does not exist, the function returns null.
Parameters
- $request : ServerRequestInterface|null
-
The PSR-7 server request instance.
- $name : string
-
The parameter name or nested key path (e.g.
'geo.latitude').
Tags
Return values
mixed —The parameter value if found, or null otherwise.