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