To make use of request instance in your controller class you can call $this->request
or initialize Request
class based on your application requirement.
namespace App\Controllers;
use Luminova\Base\BaseController;
class UserController extends BaseController
{
/** @var \ Luminova\Http\Request $this->request */
/** @var \ Luminova\Application $this->app */
/** @var \Luminova\Security\InputValidator $this->validate */
}
Get request method
$this->request->getMethod()
Get request value from GET
method
$this->request->get("name");
//OR
$this->request->get("name", "default name");
Get request value from
$this->request->find("POST", "name");
//OR
$this->request->find("POST", "name", "default name");
Other similar getters
$this->request->getPost($field, $default)
$this->request->getPut($field, $default)
$this->request->getDelete($field, $default)
$this->request->getOption($field, $default)
$this->request->getPatch($field, $default)
$this->request->getHead($field, $default)
$this->request->getConnect($field, $default)
$this->request->getTrace($field, $default)
$this->request->getPropfind($field, $default)
$this->request->getMkcol($field, $default)
$this->request->getCopy($field, $default)
$this->request->getMove($field, $default)
$this->request->getLock($field, $default)
$this->request->getUnlock($field, $default)
Get request body
$this->request->getBody(): array
Get request body
$this->request->getBodyAsObject(): object
Get request upload file info object
$this->request->getFiles(): ?object
Get request upload file by filed name and return an object of file info or null
$this->request->getFile('file name'): ?object
Get authorization header
$this->request->getAuthorization(): string
Get access token from header
$this->request->getAuthBearer(): ?string
Check if the current connection is secure
$this->request->isSecure(): bool
Check if request is ajax request
$this->request->isAJAX(): bool
Test to see if a request was made from the command line.
$this->request->isCommandLine(): bool
Get request url
$this->request->getUri(): string
Get user browser info
$this->request->getBrowser(): string
Get user agent string
$this->request->getUserAgent(): string
Check if request header exist
$this->request->hasHeader("Foo"): bool
Get request header by key name.
$this->request->header('Foo'): ?Header
Get request headers
$this->request->getHeaders(): array
Creating and managing application database