Symfony Request

[Solved] Symfony Request | Php Frameworks Symfony - Code Explorer | yomemimo.com
Question : symfony set content type

Answered by : arex

use Symfony\Component\HttpFoundation\Response;
$response = new Response();
$response->setContent(json_encode([ 'data' => 123,
]));
$response->headers->set('Content-Type', 'application/json');

Source : https://symfony.com/doc/current/components/http_foundation.html#creating-a-json-response | Last Update : Wed, 16 Dec 20

Question : symfony request type

Answered by : cadoteu

public function myAction(Request $request)
{ if ($request->isMethod('POST')) { }
}

Source : https://stackoverflow.com/questions/22852305/how-can-i-check-if-request-was-a-post-or-get-request-in-symfony2-or-symfony3/40809108 | Last Update : Sun, 17 Oct 21

Question : symfony request

Answered by : cadoteu

if ($request->isMethod('POST')) {...} //or GET

Source : | Last Update : Sun, 17 Oct 21

Answers related to symfony request

Code Explorer Popular Question For Php Frameworks Symfony