[MANUAL] English:
[zend.git] / documentation / manual / en / module_specs / Zend_Controller-Plugins-PutHandler.xml
blob218dee0f3a60d6c6a91054cf387064c27c2683f3
1 <?xml version="1.0" encoding="UTF-8"?>
2 <!-- Reviewed: no -->
3 <sect3 id="zend.controller.plugins.standard.puthandler">
4     <title>Zend_Controller_Plugin_PutHandler</title>
6     <para>
7         <classname>Zend_Controller_Plugin_PutHandler</classname> provides a drop-in
8         plugin for marshalling <constant>PUT</constant> request bodies into request parameters, just
9         like <constant>POST</constant> request bodies. It will inspect the request and, if
10         <constant>PUT</constant>, will use parse_str to parse the raw <constant>PUT</constant> body
11         into an array of params which is then set on the request. E.g.,
12     </para>
14     <programlisting language="txt"><![CDATA[
15 PUT /notes/5.xml HTTP/1.1
17 title=Hello&body=World
18 ]]></programlisting>
20     <para>
21         To receive the 'title' and 'body' params as regular request params,
22         register the plugin:
23     </para>
25     <programlisting language="php"><![CDATA[
26 $front = Zend_Controller_Front::getInstance();
27 $front->registerPlugin(new Zend_Controller_Plugin_PutHandler());
28 ]]></programlisting>
30     <para>
31         Then you can access the <constant>PUT</constant> body params by name from the request inside
32         your controller:
33     </para>
35     <programlisting language="php"><![CDATA[
36 ...
37 public function putAction()
39     $title = $this->getRequest()->getParam('title'); // $title = "Hello"
40     $body = $this->getRequest()->getParam('body'); // $body = "World"
42 ...
43 ]]></programlisting>
44 </sect3>