symfony 4/5 controller/action Cheatsheet

Get Request Params

https://symfony.com/doc/5.4/controller.html#the-request-and-response-object

  • $request->headers->all()
  • GET: $request->query->all()
  • POST: $request->request->all()
  • e.g. JSON payload: $request->getContent() + json_decode()
  • $request->server->all()

 

Get env/debug

  • $this->getParameter('kernel.environment')  // prod, dev
    
    $this->getParameter('kernel.debug') // true, false