Zend_Serializer-Adapter.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414
  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>
  120. See <link linkend="zend.json.advanced.objects1">this section</link>
  121. </entry>
  122. </row>
  123. <row>
  124. <entry><emphasis>objectDecodeType</emphasis></entry>
  125. <entry><type>Zend_Json::TYPE_*</type></entry>
  126. <entry>Zend_Json::TYPE_ARRAY</entry>
  127. <entry>
  128. See <link linkend= "zend.json.advanced.objects1">this section</link>
  129. </entry>
  130. </row>
  131. <row>
  132. <entry><emphasis>enableJsonExprFinder</emphasis></entry>
  133. <entry><type>boolean</type></entry>
  134. <entry>false</entry>
  135. <entry>
  136. See <link linkend= "zend.json.advanced.expr">this section</link>
  137. </entry>
  138. </row>
  139. </tbody>
  140. </tgroup>
  141. </table>
  142. </sect2>
  143. <sect2 id="zend.serializer.adapter.amf03">
  144. <title>Zend_Serializer_Adapter_Amf 0 and 3</title>
  145. <para>
  146. The <acronym>AMF</acronym> adapters, <classname>Zend_Serializer_Adapter_Amf0</classname>
  147. and <classname>Zend_Serializer_Adapter_Amf3</classname>, provide a bridge to the
  148. serializer of the <classname>Zend_Amf</classname> component. Please read the <link
  149. linkend= "zend.amf.introduction">Zend_Amf documentation</link> for further
  150. information.
  151. </para>
  152. <para>
  153. There are no options for these adapters.
  154. </para>
  155. </sect2>
  156. <sect2 id="zend.serializer.adapter.pythonpickle">
  157. <title>Zend_Serializer_Adapter_PythonPickle</title>
  158. <para>
  159. This adapter converts <acronym>PHP</acronym> types to a <ulink
  160. url="http://docs.python.org/library/pickle.html">Python Pickle</ulink> string
  161. representation. With it, you can read the serialized data with Python and read Pickled
  162. data of Python with <acronym>PHP</acronym>.
  163. </para>
  164. <para>
  165. Available options include:
  166. </para>
  167. <table id="zend.serializer.adapter.pythonpickle.table.options">
  168. <title>Zend_Serializer_Adapter_PythonPickle Options</title>
  169. <tgroup cols="4">
  170. <thead>
  171. <row>
  172. <entry>Option</entry>
  173. <entry>Data Type</entry>
  174. <entry>Default Value</entry>
  175. <entry>Description</entry>
  176. </row>
  177. </thead>
  178. <tbody>
  179. <row>
  180. <entry><emphasis>protocol</emphasis></entry>
  181. <entry><type>integer</type> (0 | 1 | 2 | 3)</entry>
  182. <entry>0</entry>
  183. <entry>
  184. The Pickle protocol version used on
  185. <methodname>serialize</methodname>
  186. </entry>
  187. </row>
  188. </tbody>
  189. </tgroup>
  190. </table>
  191. <para>
  192. Datatype merging (PHP to Python) occurs as follows:
  193. </para>
  194. <table id="zend.serializer.adapter.pythonpickle.table.php2python">
  195. <title>Datatype merging (PHP to Python)</title>
  196. <tgroup cols="2">
  197. <thead>
  198. <row>
  199. <entry>PHP Type</entry>
  200. <entry>Python Type</entry>
  201. </row>
  202. </thead>
  203. <tbody>
  204. <row>
  205. <entry><type>NULL</type></entry>
  206. <entry><type>None</type></entry>
  207. </row>
  208. <row>
  209. <entry><type>boolean</type></entry>
  210. <entry><type>boolean</type></entry>
  211. </row>
  212. <row>
  213. <entry><type>integer</type></entry>
  214. <entry><type>integer</type></entry>
  215. </row>
  216. <row>
  217. <entry><type>float</type></entry>
  218. <entry><type>float</type></entry>
  219. </row>
  220. <row>
  221. <entry><type>string</type></entry>
  222. <entry><type>string</type></entry>
  223. </row>
  224. <row>
  225. <entry><type>array</type></entry>
  226. <entry><type>list</type></entry>
  227. </row>
  228. <row>
  229. <entry><type>associative array</type></entry>
  230. <entry><type>dictionary</type></entry>
  231. </row>
  232. <row>
  233. <entry><type>object</type></entry>
  234. <entry><type>dictionary</type></entry>
  235. </row>
  236. </tbody>
  237. </tgroup>
  238. </table>
  239. <para>
  240. Datatype merging (Python to <acronym>PHP</acronym>) occurs per the following:
  241. </para>
  242. <table id="zend.serializer.adapter.pythonpickle.table.python2php">
  243. <title>Datatype merging (Python to PHP)</title>
  244. <tgroup cols="2">
  245. <thead>
  246. <row>
  247. <entry>Python-Type</entry>
  248. <entry>PHP-Type</entry>
  249. </row>
  250. </thead>
  251. <tbody>
  252. <row>
  253. <entry><type>None</type></entry>
  254. <entry><type>NULL</type></entry>
  255. </row>
  256. <row>
  257. <entry><type>boolean</type></entry>
  258. <entry><type>boolean</type></entry>
  259. </row>
  260. <row>
  261. <entry><type>integer</type></entry>
  262. <entry><type>integer</type></entry>
  263. </row>
  264. <row>
  265. <entry><type>long</type></entry>
  266. <entry>
  267. <type>integer</type> | <type>float</type> | <type>string</type>
  268. | <classname>Zend_Serializer_Exception</classname>
  269. </entry>
  270. </row>
  271. <row>
  272. <entry><type>float</type></entry>
  273. <entry><type>float</type></entry>
  274. </row>
  275. <row>
  276. <entry><type>string</type></entry>
  277. <entry><type>string</type></entry>
  278. </row>
  279. <row>
  280. <entry><type>bytes</type></entry>
  281. <entry><type>string</type></entry>
  282. </row>
  283. <row>
  284. <entry><type>Unicode string</type></entry>
  285. <entry><type>UTF-8 string</type></entry>
  286. </row>
  287. <row>
  288. <entry><type>list</type></entry>
  289. <entry><type>array</type></entry>
  290. </row>
  291. <row>
  292. <entry><type>tuple</type></entry>
  293. <entry><type>array</type></entry>
  294. </row>
  295. <row>
  296. <entry><type>dictionary</type></entry>
  297. <entry><type>associative array</type></entry>
  298. </row>
  299. <row>
  300. <entry>All other types</entry>
  301. <entry><classname>Zend_Serializer_Exception</classname></entry>
  302. </row>
  303. </tbody>
  304. </tgroup>
  305. </table>
  306. </sect2>
  307. <sect2 id="zend.serializer.adapter.phpcode">
  308. <title>Zend_Serializer_Adapter_PhpCode</title>
  309. <para>
  310. This adapter generates a parsable <acronym>PHP</acronym> code representation using
  311. <ulink url="http://php.net/manual/function.var-export.php">var_export()</ulink>. On
  312. restoring, the data will be executed using <ulink
  313. url="http://php.net/manual/function.eval.php">eval</ulink>.
  314. </para>
  315. <para>
  316. There are no configuration options for this adapter.
  317. </para>
  318. <warning>
  319. <title>Unserializing objects</title>
  320. <para>
  321. Objects will be serialized using the <ulink
  322. url="http://php.net/manual/language.oop5.magic.php#language.oop5.magic.set-state">__set_state</ulink>
  323. magic method. If the class doesn't implement this method, a fatal error will occur
  324. during execution.
  325. </para>
  326. </warning>
  327. <warning>
  328. <title>Uses eval()</title>
  329. <para>
  330. The <classname>PhpCode</classname> adapter utilizes <methodname>eval()</methodname>
  331. to unserialize. This introduces both a performance and potential security issue as a
  332. new process will be executed. Typically, you should use the
  333. <methodname>PhpSerialize</methodname> adapter unless you require human-readability
  334. of the serialized data.
  335. </para>
  336. </warning>
  337. </sect2>
  338. </sect1>
  339. <!--
  340. vim:se ts=4 sw=4 et:
  341. -->