PHP Library for Serialized Data
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


  Serialized - PHP Library for Serialized Data

  Copyright (C) 2010-2011 Tom Klingenberg, some rights reserved

    This program is free software: you can redistribute it and/or modify
    it under the terms of the GNU Affero General Public License as
    published by the Free Software Foundation, either version 3 of the
    License, or (at your option) any later version.

    See COPYING.


    Serialized is a set of classes that can parse serialized data into a
  normalized representation (semi structured data or S-expression).

    The base service is to parse serialized data into a so called Array
  Notation which represents both structure and the value(s) of PHP
  serialized data. See ARRAYNOT.

    This can be used to inspect and validate serialized data w/o the need
  to unserialize it first. For example if waking up sleeping objects is
  unwanted (parsing instead the factual process of unserializing). The
  parsed data can then be inspected and changed.

    Serialized variables (Sessions) are supported as well. Those are
  a list of serialized values with their variable name.

    Potential field of use is static data analysis, session display,
  inspection and manipulation of serialized data, converting etc. .

    Right now, the library can already do both: parsing into the Array
  Notation and dumping it into serialized data again. Output into other
  formats (Text, XML, ...) is possible as well.

    The following output formats to display serialized data and sessions
  are - as of now - available (example of a serialized array data sample
  dumped differently):

    * Text - Plain text, suitable for display in a shell environment.

        `-- array(4):
             +-- [user] => string(9): "user-name"
             +-- [network] => array(1):
             |    `-- [localip] => string(7): ""
             +-- [2] => string(4): "Zwei"
             `-- [language] => string(6): "german"

    * XML - Well-formed, machine readable and easy to convert.

        <?xml version="1.0" encoding="us-ascii"?>
          <array members="4">
            <item name="user" type="string">
              <string len="9" value="user-name"/>
            <item name="network" type="string">
              <array members="1">
                <item name="localip" type="string">
                  <string len="7" value=""/>
            <item name="2" type="int">
              <string len="4" value="Zwei"/>
            <item name="language" type="string">
              <string len="6" value="german"/>

    * Serialized - To store back.


    The library sources contain a test-suite to guarantee a certain level
  of confidence and strictness.

    If you run into any problems with serialized data on your end, please
  report back as this improves the library. This will help to break the
  parser so to reproduce and extend the test-suite with abstracted
  serialized data for future regression testing.

    Naturally private data will be anonmyzed before it is put into the test-
  suite and generally it will not be published w/o a written consent.

    Feedback of any kind is always warmheartly appreciated.


    PHP 5.3.3 or higher
    PHPUNIT 3.5.5 or higher (for the test-suite)


      To make use of the library, copy over the src directory into your
    library folder.

      Serialized ships with a PSR-0 compatbile autoloader. To make use of the
    library require the base file:


      After including it (the autoloader), auto-loading is enabled and the
    parser and the dumpers can be used:

      $array = Serialized\Parser::parse($serialized);

      Example: 00-basic-parsing

      Instead of using the autoloader, the library can be manually loaded as


      For debugging purposes, there is a dump function which prints structure
    and data of a serialized string to standard output:

      $parser = new Serialized\Parser($serialized);

      Example: 01-debug-dump


    PHP Serialize Function (PHP Manual)

    PHP Unserialize Function (PHP Manual)

    Object Serialization (PHP Manual)

    The Serializable interface (PHP Manual)

    Runtime Configuration "unserialize_callback_func" (PHP Manual)

    PHP Session Decode Function (PHP Manual)

    PHP Serialize C Sourcecode

    PHP Unserialize C Sourcecode

    PHP Serialization And Recursion Demystified (by Andrea Giammarchi; 2009-09-07)

    Recursive Reference Serialize Library (by Nghia Nguyen; 2009-06-01)