DLight\Application\Request
Mô tả: wrapper đọc dữ liệu request hiện tại: method/uri, query (GET), body (POST/JSON), headers, cookies và server vars.
Namespace / đăng ký
- Namespace:
DLight\Application - File:
src/Application/Request.php
Public API
__construct()getMethod(): stringgetUri(): stringgetQueryParams(): arraygetBodyParams(): arraygetHeaders(): arraygetHeader(string $key, mixed $default = null): mixedgetCookies(): arraycookie(string $key, mixed $default = null): mixedgetServer(): arrayinput(string $key, mixed $default = null): mixedall(): array
Cách dùng + demo
use DLight\Application\Request;
$req = new Request();
$method = $req->getMethod();
$uri = $req->getUri();
$page = $req->input('page', 1); // ưu tiên body, fallback query
$token = $req->getHeader('X-CSRF-TOKEN'); // header keys đã normalize lowercase
$data = $req->all();
Body sẽ được parse theo Content-Type:
application/json → decode JSON,
x-www-form-urlencoded / multipart/form-data → $_POST,
còn lại → lưu raw vào ['_raw'].