skillfed

phpserialize

a port of the serialize and unserialize functions of php to python.

phpserialize v1.3 272.7K downloads/30d#8,207 on PyPI132
Permissive license UNKNOWN DORMANT released

What it is and what it does

phpserialize is a Python port of PHP's serialize and unserialize functions, enabling bidirectional conversion between Python objects and PHP serialization format. It implements the standard Python serialization interface with `dumps`, `loads`, and file-like object support.

The package handles PHP's type system differences: lists become dicts (with integer keys), unicode strings are UTF-8 encoded by default, and None/floats/booleans are converted to PHP-compatible types. It also supports PHP object serialization through hooks and provides helper functions like `dict_to_list` and `dict_to_tuple` to recover Python data structures. Version 1.3 added Python 3 support using the 'surrogateescape' error handler for bytes/unicode handling.

Use it for:

  • Deserialize PHP session data or cache stored in PHP format within a Python application
  • Exchange structured data between PHP and Python services without JSON/XML conversion overhead
  • Migrate or synchronize data from PHP applications to Python backends while preserving PHP object metadata
  • Test PHP serialization logic in Python test suites by round-tripping PHP-serialized objects
  • Parse WordPress or other PHP framework object data in Python analysis or migration tools

Worth the install?

AI-flagged interpretation of the facts on this page — verify before relying

Converts Python objects to and from PHP serialization format, implementing the `dumps`/`loads` interface for cross-language data exchange.

Yes, but with caution. The package is stable for basic PHP serialization tasks and carries no known vulnerabilities, but it has been dormant since 2012 with minimal maintenance. Install if you have a specific need to interoperate with PHP serialized data and accept that bug fixes or Python version compatibility updates are unlikely. For new projects, consider whether JSON or another standard format would reduce coupling to PHP.

Install

phpserialize on PyPI

pip

pip install phpserialize

uv

uv add phpserialize

poetry

poetry add phpserialize

Installing phpserialize

Before you install

High install friction due to source-only distribution. Package is dormant since 2012 with no recent maintenance, though the repository shows a recent commit in 2024. No runtime dependencies.

License in practice

Licensed under BSD (permissive), allowing commercial and private use with minimal restrictions.

Quickstart

from phpserialize import dumps, loads

# Serialize a Python string
obj = dumps("Hello World")
print(loads(obj))  # 'Hello World'

# Handle lists (serialized as dicts in PHP)
from phpserialize import dict_to_list
result = dict_to_list(loads(dumps([1, 2, 3])))
print(result)  # [1, 2, 3]

No Python version requirement specified; test compatibility with your target Python version before production use.

Verify before relying

  • Whether the 2024 repository commit represents active maintenance or a one-off update
  • Python 3 compatibility status beyond the version 1.3 changelog note
  • Whether binary data handling via 'surrogateescape' is production-ready

Package facts

License UNKNOWN (permissive)
Python support not specified
Install friction high — source build required
Runtime dependencies none
Maintenance dormant — 5,318 days since the last release
Last repo commit
First released
Downloads 272,666/month — #8,207 on PyPI (30-day window, as of 2026-08-14)
Known vulnerabilities none known (OSV.dev, checked 2026-08-14)

Evidence: phpserialize-1.3.tar.gz

License :: OSI Approved :: BSD LicenseProgramming Language :: PHPProgramming Language :: PythonProgramming Language :: Python :: 3

Tags

php serialization pythonserialize unserialize phpphp data format pythoncross-language object serializationphp compatible serialization
php-interopserialization

More Software Development packages