Code snippets for symfony 1.x


Refine Tags

Snippets tagged "post"

Getting Raw Data From POSTed Body

I tried to find a way to get the raw data from the body of a HTTP request. In my case the request contained an XML document upon which my action had to act.

One of the options was to use the global $HTTP_RAW_POST_DATA. However, this required altering the php.ini file.

The preferred way to achieve this eventually was to use the php://input stream wrapper. For instance, in my case the following read the XML from the request body and converts it to XML using SimpleXML:

  public function executeTest() {
         $this->xml = simplexml_load_file('php://input');
         return sfView::SUCCESS;

Note: It won't work in cases where enctype="multipart/form-data". More infromation about this and other PHP wrappers can be found at

by Avi Cohen on 2006-11-07, tagged body  post  raw  wrapper  xml