Zend_Serializer-Adapter.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405
  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <!-- Reviewed: no -->
  3. <sect1 id="zend.serializer.adapter">
  4. <title>Zend_Serializer_Adapter</title>
  5. <para>
  6. <classname>Zend_Serializer</classname> adapters create a bridge for different methods of
  7. serializing with very little effort.
  8. </para>
  9. <para>
  10. Every adapter has different pros and cons. In some cases, not every <acronym>PHP</acronym>
  11. datatype (e.g., objects) can be converted to a string representation. In most such cases,
  12. the type will be converted to a similar type that is serializable -- as an example,
  13. <acronym>PHP</acronym> objects will often be cast to arrays. If this fails, a
  14. <classname>Zend_Serializer_Exception</classname> will be thrown.
  15. </para>
  16. <para>
  17. Below is a list of available adapters.
  18. </para>
  19. <sect2 id="zend.serializer.adapter.phpserialize">
  20. <title>Zend_Serializer_Adapter_PhpSerialize</title>
  21. <para>
  22. This adapter uses the built-in <methodname>un/serialize</methodname>
  23. <acronym>PHP</acronym> functions, and is a good default adapter choice.
  24. </para>
  25. <para>
  26. There are no configurable options for this adapter.
  27. </para>
  28. </sect2>
  29. <sect2 id="zend.serializer.adapter.igbinary">
  30. <title>Zend_Serializer_Adapter_Igbinary</title>
  31. <para>
  32. <ulink url="http://opensource.dynamoid.com">Igbinary</ulink> is Open Source Software
  33. released by Sulake Dynamoid Oy. It's a drop-in replacement for the standard
  34. <acronym>PHP</acronym> serializer. Instead of time and space consuming textual
  35. representation, igbinary stores <acronym>PHP</acronym> data structures in a compact
  36. binary form. Savings are significant when using memcached or similar memory based
  37. storages for serialized data.
  38. </para>
  39. <para>
  40. You need the igbinary <acronym>PHP</acronym> extension installed on your system in order
  41. to use this adapter.
  42. </para>
  43. <para>
  44. There adapter takes no configuration options.
  45. </para>
  46. </sect2>
  47. <sect2 id="zend.serializer.adapter.wddx">
  48. <title>Zend_Serializer_Adapter_Wddx</title>
  49. <para>
  50. <ulink url="http://wikipedia.org/wiki/WDDX">WDDX</ulink> (Web Distributed Data eXchange)
  51. is a programming-language-, platform-, and transport-neutral data interchange mechanism
  52. for passing data between different environments and different computers.
  53. </para>
  54. <para>
  55. The adapter simply uses the <ulink
  56. url="http://php.net/manual/book.wddx.php">wddx_*()</ulink> <acronym>PHP</acronym>
  57. functions. Please read the <acronym>PHP</acronym> manual to determine how you may enable
  58. them in your <acronym>PHP</acronym> installation.
  59. </para>
  60. <para>
  61. Additionally, the <ulink
  62. url="http://php.net/manual/book.simplexml.php">SimpleXML</ulink>
  63. <acronym>PHP</acronym> extension is used to check if a returned
  64. <constant>NULL</constant> value from <methodname>wddx_unserialize()</methodname> is
  65. based on a serialized <constant>NULL</constant> or on invalid data.
  66. </para>
  67. <para>
  68. Available options include:
  69. </para>
  70. <table id="zend.serializer.adapter.wddx.table.options">
  71. <title>Zend_Serializer_Adapter_Wddx Options</title>
  72. <tgroup cols="4">
  73. <thead>
  74. <row>
  75. <entry>Option</entry>
  76. <entry>Data Type</entry>
  77. <entry>Default Value</entry>
  78. <entry>Description</entry>
  79. </row>
  80. </thead>
  81. <tbody>
  82. <row>
  83. <entry><emphasis>comment</emphasis></entry>
  84. <entry><type>string</type></entry>
  85. <entry></entry>
  86. <entry>An optional comment that appears in the packet header.</entry>
  87. </row>
  88. </tbody>
  89. </tgroup>
  90. </table>
  91. </sect2>
  92. <sect2 id="zend.serializer.adapter.json">
  93. <title>Zend_Serializer_Adapter_Json</title>
  94. <para>
  95. The <acronym>JSON</acronym> adapter provides a bridge to the
  96. <classname>Zend_Json</classname> component and/or ext/json. Please read the <link
  97. linkend= "zend.json.introduction">Zend_Json documentation</link> for further
  98. information.
  99. </para>
  100. <para>
  101. Available options include:
  102. </para>
  103. <table id="zend.serializer.adapter.json.table.options">
  104. <title>Zend_Serializer_Adapter_Json Options</title>
  105. <tgroup cols="4">
  106. <thead>
  107. <row>
  108. <entry>Option</entry>
  109. <entry>Data Type</entry>
  110. <entry>Default Value</entry>
  111. <entry>Description</entry>
  112. </row>
  113. </thead>
  114. <tbody>
  115. <row>
  116. <entry><emphasis>cycleCheck</emphasis></entry>
  117. <entry><type>boolean</type></entry>
  118. <entry>false</entry>
  119. <entry>See <xref linkend="zend.json.advanced.objects1"/></entry>
  120. </row>
  121. <row>
  122. <entry><emphasis>objectDecodeType</emphasis></entry>
  123. <entry><type>Zend_Json::TYPE_*</type></entry>
  124. <entry>Zend_Json::TYPE_ARRAY</entry>
  125. <entry>See <xref linkend= "zend.json.advanced.objects1"/></entry>
  126. </row>
  127. <row>
  128. <entry><emphasis>enableJsonExprFinder</emphasis></entry>
  129. <entry><type>boolean</type></entry>
  130. <entry>false</entry>
  131. <entry>See <xref linkend= "zend.json.advanced.expr"/></entry>
  132. </row>
  133. </tbody>
  134. </tgroup>
  135. </table>
  136. </sect2>
  137. <sect2 id="zend.serializer.adapter.amf03">
  138. <title>Zend_Serializer_Adapter_Amf 0 and 3</title>
  139. <para>
  140. The <acronym>AMF</acronym> adapters, <classname>Zend_Serializer_Adapter_Amf0</classname>
  141. and <classname>Zend_Serializer_Adapter_Amf3</classname>, provide a bridge to the
  142. serializer of the <classname>Zend_Amf</classname> component. Please read the <link
  143. linkend= "zend.amf.introduction">Zend_Amf documentation</link> for further
  144. information.
  145. </para>
  146. <para>
  147. There are no options for these adapters.
  148. </para>
  149. </sect2>
  150. <sect2 id="zend.serializer.adapter.pythonpickle">
  151. <title>Zend_Serializer_Adapter_PythonPickle</title>
  152. <para>
  153. This adapter converts <acronym>PHP</acronym> types to a <ulink
  154. url="http://docs.python.org/library/pickle.html">Python Pickle</ulink> string
  155. representation. With it, you can read the serialized data with Python and read Pickled
  156. data of Python with <acronym>PHP</acronym>.
  157. </para>
  158. <para>
  159. Available options include:
  160. </para>
  161. <table id="zend.serializer.adapter.pythonpickle.table.options">
  162. <title>Zend_Serializer_Adapter_PythonPickle Options</title>
  163. <tgroup cols="4">
  164. <thead>
  165. <row>
  166. <entry>Option</entry>
  167. <entry>Data Type</entry>
  168. <entry>Default Value</entry>
  169. <entry>Description</entry>
  170. </row>
  171. </thead>
  172. <tbody>
  173. <row>
  174. <entry><emphasis>protocol</emphasis></entry>
  175. <entry><type>integer</type> (0 | 1 | 2 | 3)</entry>
  176. <entry>0</entry>
  177. <entry>
  178. The Pickle protocol version used on
  179. <methodname>serialize</methodname>
  180. </entry>
  181. </row>
  182. </tbody>
  183. </tgroup>
  184. </table>
  185. <para>
  186. Datatype merging (PHP to Python) occurs as follows:
  187. </para>
  188. <table id="zend.serializer.adapter.pythonpickle.table.php2python">
  189. <title>Datatype merging (PHP to Python)</title>
  190. <tgroup cols="2">
  191. <thead>
  192. <row>
  193. <entry>PHP Type</entry>
  194. <entry>Python Type</entry>
  195. </row>
  196. </thead>
  197. <tbody>
  198. <row>
  199. <entry><type>NULL</type></entry>
  200. <entry><type>None</type></entry>
  201. </row>
  202. <row>
  203. <entry><type>boolean</type></entry>
  204. <entry><type>boolean</type></entry>
  205. </row>
  206. <row>
  207. <entry><type>integer</type></entry>
  208. <entry><type>integer</type></entry>
  209. </row>
  210. <row>
  211. <entry><type>float</type></entry>
  212. <entry><type>float</type></entry>
  213. </row>
  214. <row>
  215. <entry><type>string</type></entry>
  216. <entry><type>string</type></entry>
  217. </row>
  218. <row>
  219. <entry><type>array</type></entry>
  220. <entry><type>list</type></entry>
  221. </row>
  222. <row>
  223. <entry><type>associative array</type></entry>
  224. <entry><type>dictionary</type></entry>
  225. </row>
  226. <row>
  227. <entry><type>object</type></entry>
  228. <entry><type>dictionary</type></entry>
  229. </row>
  230. </tbody>
  231. </tgroup>
  232. </table>
  233. <para>
  234. Datatype merging (Python to <acronym>PHP</acronym>) occurs per the following:
  235. </para>
  236. <table id="zend.serializer.adapter.pythonpickle.table.python2php">
  237. <title>Datatype merging (Python to PHP)</title>
  238. <tgroup cols="2">
  239. <thead>
  240. <row>
  241. <entry>Python-Type</entry>
  242. <entry>PHP-Type</entry>
  243. </row>
  244. </thead>
  245. <tbody>
  246. <row>
  247. <entry><type>None</type></entry>
  248. <entry><type>NULL</type></entry>
  249. </row>
  250. <row>
  251. <entry><type>boolean</type></entry>
  252. <entry><type>boolean</type></entry>
  253. </row>
  254. <row>
  255. <entry><type>integer</type></entry>
  256. <entry><type>integer</type></entry>
  257. </row>
  258. <row>
  259. <entry><type>long</type></entry>
  260. <entry>
  261. <type>integer</type> | <type>float</type> | <type>string</type>
  262. | <classname>Zend_Serializer_Exception</classname>
  263. </entry>
  264. </row>
  265. <row>
  266. <entry><type>float</type></entry>
  267. <entry><type>float</type></entry>
  268. </row>
  269. <row>
  270. <entry><type>string</type></entry>
  271. <entry><type>string</type></entry>
  272. </row>
  273. <row>
  274. <entry><type>bytes</type></entry>
  275. <entry><type>string</type></entry>
  276. </row>
  277. <row>
  278. <entry><type>Unicode string</type></entry>
  279. <entry><type>UTF-8 string</type></entry>
  280. </row>
  281. <row>
  282. <entry><type>list</type></entry>
  283. <entry><type>array</type></entry>
  284. </row>
  285. <row>
  286. <entry><type>tuple</type></entry>
  287. <entry><type>array</type></entry>
  288. </row>
  289. <row>
  290. <entry><type>dictionary</type></entry>
  291. <entry><type>associative array</type></entry>
  292. </row>
  293. <row>
  294. <entry>All other types</entry>
  295. <entry><classname>Zend_Serializer_Exception</classname></entry>
  296. </row>
  297. </tbody>
  298. </tgroup>
  299. </table>
  300. </sect2>
  301. <sect2 id="zend.serializer.adapter.phpcode">
  302. <title>Zend_Serializer_Adapter_PhpCode</title>
  303. <para>
  304. This adapter generates a parsable <acronym>PHP</acronym> code representation using
  305. <ulink url="http://php.net/manual/function.var-export.php">var_export()</ulink>. On
  306. restoring, the data will be executed using <ulink
  307. url="http://php.net/manual/function.eval.php">eval</ulink>.
  308. </para>
  309. <para>
  310. There are no configuration options for this adapter.
  311. </para>
  312. <warning>
  313. <title>Unserializing objects</title>
  314. <para>
  315. Objects will be serialized using the <ulink
  316. url="http://php.net/manual/language.oop5.magic.php#language.oop5.magic.set-state">__set_state</ulink>
  317. magic method. If the class doesn't implement this method, a fatal error will occur
  318. during execution.
  319. </para>
  320. </warning>
  321. <warning>
  322. <title>Uses eval()</title>
  323. <para>
  324. The <classname>PhpCode</classname> adapter utilizes <methodname>eval()</methodname>
  325. to unserialize. This introduces both a performance and potential security issue as a
  326. new process will be executed. Typically, you should use the
  327. <methodname>PhpSerialize</methodname> adapter unless you require human-readability
  328. of the serialized data.
  329. </para>
  330. </warning>
  331. </sect2>
  332. </sect1>
  333. <!--
  334. vim:se ts=4 sw=4 et:
  335. -->