Php 访问RESTAPI中的自定义头信息

Php 访问RESTAPI中的自定义头信息,php,rest,symfony,fosrestbundle,Php,Rest,Symfony,Fosrestbundle,是否有任何方法可以使用fosrest访问自定义标题信息?我已经在我的客户机中添加了头数据,但我不知道如何在我的服务器中获取它 /** * @Rest\Get("/batch") */ public function getBatchAction(\FOS\RestBundle\Request\ParamFetcher $paramFetcher){ } 我不想通过get或post传递这个参数,它是一个永久值,就像代码或其他东西一样,将在每个请求中,根据用户的不同而变化 谢谢。谢谢安德烈

是否有任何方法可以使用fosrest访问自定义标题信息?我已经在我的客户机中添加了头数据,但我不知道如何在我的服务器中获取它

/**
 * @Rest\Get("/batch")
 */
public function getBatchAction(\FOS\RestBundle\Request\ParamFetcher $paramFetcher){ 

}
我不想通过get或post传递这个参数,它是一个永久值,就像代码或其他东西一样,将在每个请求中,根据用户的不同而变化


谢谢。

谢谢安德烈,我能找到这个答案:

public function getBatchAction(Request $request, \FOS\RestBundle\Request\ParamFetcher $paramFetcher){           
    return $request->headers->get('customheader');
}

使用这个名称空间:Symfony\Component\HttpFoundation

感谢Andrey,我可以找到以下答案:

public function getBatchAction(Request $request, \FOS\RestBundle\Request\ParamFetcher $paramFetcher){           
    return $request->headers->get('customheader');
}

使用此命名空间:Symfony\Component\HttpFoundation

是否尝试使用
请求->标题->获取('customHeader')
访问它?是否尝试使用
请求->标题->获取('customHeader')
访问它?