Zend_Serializer-Adapter.xml 15 KB

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