Zend_Serializer-Adapter.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456
  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 PHP datatype (e.g.,
  11. objects) can be converted to a string representation. In most such cases, the type will be
  12. converted to a similar type that is serializable -- as an example, PHP objects will often be
  13. cast to arrays. If this fails, a <classname>Zend_Serializer_Exception</classname> will be
  14. 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> PHP functions, and
  23. 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 PHP
  34. serializer. Instead of time and space consuming textual representation, igbinary stores
  35. PHP data structures in a compact binary form. Savings are significant when using
  36. memcached or similar memory based storages for serialized data.
  37. </para>
  38. <para>
  39. You need the igbinary PHP extension installed on your system in order to use this
  40. adapter.
  41. </para>
  42. <para>
  43. There adapter takes no configuration options.
  44. </para>
  45. </sect2>
  46. <sect2 id="zend.serializer.adapter.wddx">
  47. <title>Zend_Serializer_Adapter_Wddx</title>
  48. <para>
  49. <ulink url="http://wikipedia.org/wiki/WDDX">WDDX</ulink> (Web Distributed Data eXchange)
  50. is a programming-language-, platform-, and transport-neutral data interchange mechanism
  51. for passing data between different environments and different computers.
  52. </para>
  53. <para>
  54. The adapter simply uses the <ulink url="http://php.net/manual/book.wddx.php">wddx_*()</ulink>
  55. PHP functions. Please read the php manual to determine how you may enable them in your
  56. PHP installation.
  57. </para>
  58. <para>
  59. Additionally, the <ulink
  60. url="http://php.net/manual/book.simplexml.php">SimpleXML</ulink> PHP extension is
  61. used to check if a returned <constant>NULL</constant> value from
  62. <methodname>wddx_unserialize()</methodname> is based on a serialized
  63. <constant>NULL</constant> or on invalid data.
  64. </para>
  65. <para>
  66. Available options include:
  67. </para>
  68. <table>
  69. <title>Zend_Serializer_Adapter_Wddx Options</title>
  70. <tgroup cols="4">
  71. <thead>
  72. <row>
  73. <entry>Option</entry>
  74. <entry>Data Type</entry>
  75. <entry>Default Value</entry>
  76. <entry>Description</entry>
  77. </row>
  78. </thead>
  79. <tbody>
  80. <row>
  81. <entry><emphasis>comment</emphasis></entry>
  82. <entry><type>string</type></entry>
  83. <entry></entry>
  84. <entry>
  85. An optional comment that appears in the packet header.
  86. </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>
  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 <xref linkend= "zend.json.advanced.objects1"/>
  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 <xref linkend= "zend.json.advanced.objects1"/>
  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 <xref linkend= "zend.json.advanced.expr"/>
  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 PHP 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 PHP.
  163. </para>
  164. <para>
  165. Available options include:
  166. </para>
  167. <table>
  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 <methodname>serialize</methodname>
  185. </entry>
  186. </row>
  187. </tbody>
  188. </tgroup>
  189. </table>
  190. <para>
  191. Datatype merging (PHP to Python) occurs as follows:
  192. </para>
  193. <table>
  194. <title>Datatype merging (PHP to Python)</title>
  195. <tgroup cols="2">
  196. <thead>
  197. <row>
  198. <entry>PHP Type</entry>
  199. <entry>Python Type</entry>
  200. </row>
  201. </thead>
  202. <tbody>
  203. <row>
  204. <entry><type>NULL</type></entry>
  205. <entry><type>None</type></entry>
  206. </row>
  207. <row>
  208. <entry><type>boolean</type></entry>
  209. <entry><type>boolean</type></entry>
  210. </row>
  211. <row>
  212. <entry><type>integer</type></entry>
  213. <entry><type>integer</type></entry>
  214. </row>
  215. <row>
  216. <entry><type>float</type></entry>
  217. <entry><type>float</type></entry>
  218. </row>
  219. <row>
  220. <entry><type>string</type></entry>
  221. <entry><type>string</type></entry>
  222. </row>
  223. <row>
  224. <entry><type>array</type></entry>
  225. <entry><type>list</type></entry>
  226. </row>
  227. <row>
  228. <entry><type>associative array</type></entry>
  229. <entry><type>dictionary</type></entry>
  230. </row>
  231. <row>
  232. <entry><type>object</type></entry>
  233. <entry><type>dictionary</type></entry>
  234. </row>
  235. </tbody>
  236. </tgroup>
  237. </table>
  238. <para>
  239. Datatype merging (Python to PHP) occurs per the following:
  240. </para>
  241. <table>
  242. <title>Datatype merging (Python to PHP)</title>
  243. <tgroup cols="2">
  244. <thead>
  245. <row>
  246. <entry>Python-Type</entry>
  247. <entry>PHP-Type</entry>
  248. </row>
  249. </thead>
  250. <tbody>
  251. <row>
  252. <entry><type>None</type></entry>
  253. <entry><type>NULL</type></entry>
  254. </row>
  255. <row>
  256. <entry><type>boolean</type></entry>
  257. <entry><type>boolean</type></entry>
  258. </row>
  259. <row>
  260. <entry><type>integer</type></entry>
  261. <entry><type>integer</type></entry>
  262. </row>
  263. <row>
  264. <entry><type>long</type></entry>
  265. <entry>
  266. <type>integer</type>
  267. | <type>float</type>
  268. | <type>string</type>
  269. | <classname>Zend_Serializer_Exception</classname>
  270. </entry>
  271. </row>
  272. <row>
  273. <entry><type>float</type></entry>
  274. <entry><type>float</type></entry>
  275. </row>
  276. <row>
  277. <entry><type>string</type></entry>
  278. <entry><type>string</type></entry>
  279. </row>
  280. <row>
  281. <entry><type>bytes</type></entry>
  282. <entry><type>string</type></entry>
  283. </row>
  284. <row>
  285. <entry><type>Unicode string</type></entry>
  286. <entry><type>UTF-8 string</type></entry>
  287. </row>
  288. <row>
  289. <entry><type>list</type></entry>
  290. <entry><type>array</type></entry>
  291. </row>
  292. <row>
  293. <entry><type>tuple</type></entry>
  294. <entry><type>array</type></entry>
  295. </row>
  296. <row>
  297. <entry><type>dictionary</type></entry>
  298. <entry><type>associative array</type></entry>
  299. </row>
  300. <row>
  301. <entry>All other types</entry>
  302. <entry><classname>Zend_Serializer_Exception</classname></entry>
  303. </row>
  304. </tbody>
  305. </tgroup>
  306. </table>
  307. </sect2>
  308. <sect2 id="zend.serializer.adapter.phpcode">
  309. <title>Zend_Serializer_Adapter_PhpCode</title>
  310. <para>
  311. This adapter generates a parsable PHP code representation using <ulink
  312. url="http://php.net/manual/function.var-export.php">var_export()</ulink>. On
  313. restoring, the data will be executed using <ulink
  314. url="http://php.net/manual/function.eval.php">eval</ulink>.
  315. </para>
  316. <para>
  317. There are no configuration options for this adapter.
  318. </para>
  319. <warning>
  320. <title>Unserializing objects</title>
  321. <para>
  322. Objects will be serialized using the <ulink
  323. url="http://php.net/manual/language.oop5.magic.php#language.oop5.magic.set-state">__set_state</ulink>
  324. magic method. If the class doesn't implement this method, a fatal error will occur
  325. during execution.
  326. </para>
  327. </warning>
  328. <warning>
  329. <title>Uses eval()</title>
  330. <para>
  331. The <classname>PhpCode</classname> adapter utilizes <methodname>eval()</methodname>
  332. to unserialize. This introduces both a performance and potential security issue as a
  333. new process will be executed. Typically, you should use the
  334. <methodname>PhpSerialize</methodname> adapter unless you require human-readability
  335. of the serialized data.
  336. </para>
  337. </warning>
  338. </sect2>
  339. </sect1>
  340. <!--
  341. vim:se ts=4 sw=4 et:
  342. -->