symfony create request object code example
Example 1: symfony get post params
use Symfony\Component\HttpFoundation\Request;
$request = Request::createFromGlobals();
$request->getPathInfo();
$request->query->get('id');
$request->request->get('category', 'default category');
$request->server->get('HTTP_HOST');
$request->files->get('attachment');
$request->cookies->get('PHPSESSID');
$request->headers->get('host');
$request->headers->get('content-type');
$request->getMethod();
$request->getLanguages();
Example 2: symfony set content type
use Symfony\Component\HttpFoundation\Response;
$response = new Response();
$response->setContent(json_encode([
'data' => 123,
]));
$response->headers->set('Content-Type', 'application/json');