How to get request header values in symfony

If you need to get a specific header you can use:

$request->headers->get('My-Header');

See documentation: https://symfony.com/doc/current/components/http_foundation.html#accessing-accept-headers-data


You need to pass your Request object to the controller method and then in controller use $request->headers->all()

For example:

public function testAction(Request $request)
{
    $headers = $request->headers->all();
}

You can also get Request object from a controller by calling $this->getRequest() from controller method.