Zend_Serializer-Adapter.xml 15 KB

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