| 1234567891011121314151617181920212223242526272829303132333435363738394041424344 |
- <?xml version="1.0" encoding="UTF-8"?>
- <!-- Reviewed: no -->
- <sect3 id="zend.controller.plugins.standard.puthandler">
- <title>Zend_Controller_Plugin_PutHandler</title>
- <para>
- <classname>Zend_Controller_Plugin_PutHandler</classname> provides a drop-in
- plugin for marshalling <constant>PUT</constant> request bodies into request parameters, just
- like <constant>POST</constant> request bodies. It will inspect the request and, if
- <constant>PUT</constant>, will use parse_str to parse the raw <constant>PUT</constant> body
- into an array of params which is then set on the request. E.g.,
- </para>
- <programlisting language="txt"><![CDATA[
- PUT /notes/5.xml HTTP/1.1
- title=Hello&body=World
- ]]></programlisting>
- <para>
- To receive the 'title' and 'body' params as regular request params,
- register the plugin:
- </para>
- <programlisting language="php"><![CDATA[
- $front = Zend_Controller_Front::getInstance();
- $front->registerPlugin(new Zend_Controller_Plugin_PutHandler());
- ]]></programlisting>
- <para>
- Then you can access the <constant>PUT</constant> body params by name from the request inside
- your controller:
- </para>
- <programlisting language="php"><![CDATA[
- ...
- public function putAction()
- {
- $title = $this->getRequest()->getParam('title'); // $title = "Hello"
- $body = $this->getRequest()->getParam('body'); // $body = "World"
- }
- ...
- ]]></programlisting>
- </sect3>
|