2
0

Zend_Controller-Plugins-PutHandler.xml 1.4 KB

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