Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Laminas Serializer Laravel Package

laminas/laminas-serializer

Serialize and deserialize PHP data using multiple adapters (e.g., PHP native, JSON, XML, WDDX) with consistent options, error handling, and extensibility. Useful for caching, sessions, message payloads, and storage across different formats.

View on GitHub
Deep Wiki
Context7

Adapters

laminas-serializer adapters handle serialization to and deserialization from specific representations.

Each adapter has its own strengths. In some cases, not every PHP 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, PHP objects will often be cast to arrays. If this fails, a Laminas\Serializer\Exception\ExceptionInterface will be thrown.

The PhpSerialize Adapter

The Laminas\Serializer\Adapter\PhpSerialize adapter uses the built-in serialize()/unserialize() functions, and is a good default adapter choice.

Available options include:

Option Data Type Default Value Description
unserialize_class_whitelist array or bool true The allowed classes for unserialize(), see unserialize() for more information. Only available on PHP 7.0 or higher.

The IgBinary Adapter

Igbinary was originally released by Sulake Dynamoid Oy and since 2011-03-14 moved to PECL and maintained by Pierre Joye. It's a drop-in replacement for the standard PHP serializer. Instead of using a costly textual representation, igbinary stores PHP data structures in a compact binary form. Savings are significant when using memcached or similar memory based storages for serialized data.

You need the igbinary PHP extension installed on your system in order to use this adapter.

There are no configurable options for this adapter.

The Json Adapter

The JSON adapter provides a bridge to the laminas-json component.

Available options include:

Option Data Type Default Value
cycle_check boolean false
object_decode_type Laminas\Json\Json::TYPE_* Laminas\Json\Json::TYPE_ARRAY
enable_json_expr_finder boolean false

The PhpCode Adapter

The Laminas\Serializer\Adapter\PhpCode adapter generates a parsable PHP code representation using var_export(). To restore, the data will be executed using eval.

There are no configuration options for this adapter.

Warning: Unserializing objects

Objects will be serialized using the __set_state magic method. If the class doesn't implement this method, a fatal error will occur during execution.

Warning: Uses eval()

The PhpCode adapter utilizes eval() to unserialize. This introduces both a performance and potential security issue as a new process will be executed. Typically, you should use the PhpSerialize adapter unless you require human-readability of the serialized data.

The PythonPickle Adapter

This adapter converts PHP types to a Python Pickle string representation. With it, you can read the serialized data with Python and read Pickled data from Python with PHP.

This adapter requires the laminas-math component:

$ composer require laminas/laminas-math

Available options include:

Option Data Type Default Value Description
protocol integer (0/1/2/3) 0 The Pickle protocol version used on serialize

Datatype merging (PHP to Python Pickle)

PHP Type Python Pickle Type
NULL None
boolean boolean
integer integer
float float
string string
array list list
array map dictionary
object dictionary

Datatype merging (Python Pickle to PHP)

Python Pickle Type PHP Type
None NULL
boolean boolean
integer integer
long integer, float, string, or Laminas\Serializer\Exception\ExceptionInterface
float float
string string
bytes string
unicode string string UTF-8
list array list
tuple array list
dictionary array map
All other types Laminas\Serializer\Exception\ExceptionInterface

The Wddx Adapter

WDDX (Web Distributed Data eXchange) is a programming-language-, platform-, and transport-neutral data interchange mechanism for passing data between different environments and different computers.

The adapter uses the wddx PHP functions. Please read the PHP manual to determine how you may enable them in your installation.

Additionally, the SimpleXML extension is used to check if a returned NULL value from wddx_unserialize() is based on a serialized NULL or on invalid data.

Available options include:

Option Data Type Default Value Description
comment string An optional comment that appears in the packet header.
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport
twbs/bootstrap4
php-http/client-implementation
phpcr/phpcr-implementation
cucumber/gherkin-monorepo
haydenpierce/class-finder
psr/simple-cache-implementation
uri-template/tests