PHPackages                             dale/phpickle - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. dale/phpickle

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

dale/phpickle
=============

PHP package for support python pickle format

1.0.0(2y ago)04MITPHP

Since Aug 29Pushed 2y ago1 watchersCompare

[ Source](https://github.com/Dale08/phpickle)[ Packagist](https://packagist.org/packages/dale/phpickle)[ RSS](/packages/dale-phpickle/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)DependenciesVersions (2)Used By (0)

```

Phpickle is a set of PHP classes that allow you to read and write the python
pickle format. It is useful for integrating python and php applications together,
for example to read django session data from a php application.

==============Basic usage:

----
require_once "phpickle.php";

$data = phpickle::loads($pickled_string);
---

If you want to unpickle from something that can be treated as a php stream, then:

----
require_once "phpickle.php";

$data = phpickle::load_stream("pickled_file.pickle");
$data = phpickle::load_stream("http://www.pickler.com/mydata");
// and others
---

If you want to unpickle data that was stored by the default django session handler, then:

----
require_once "phpickle.php";

$data = phpickle::loads_django_session($data_from_django_session_db);
---

If you want to pickle data, then:

---
require_once "phpickle.php";

$string = phpickle::dumps($data_to_pickle);
---

===============Current status:

Well, unpickling simple types, lists, tuples, dicts, ints, double, strings works.
Unpickling class instances also works, but of course the instances are not the same
as the ones in python. Instead stdClass instances are created, with all the data
properties that are in the pickle and a few extra ones as well:

$inst->__python_class__ = "__main__.test";
$inst->__python_construct_args__ = array();

__python_class__ is the package.class name for the python class that this instance represents.
__python_construct_args__ are the contructor arguments for creating the class instance in python.

Of course, referencing really python specific things, line REDUCE op that gives it's
argument to a python method to produce a result cannot be supported.

Pickling support is there for simple types and arrays. Experimental support for
objects is also there. Pickling back from previously unpickled data should produce
the same result most of the time, but needs better test coverage.

===============Code setup:

tests folder has phpunit based tests for some of the modules.

Pickle is a very simple stack based language, the interpreter is in
phpickle_unpickle.php and the read/write handlers for different opcodes are
in the phpickle_op_handlers.pck. To generate the interpreter files, run
make gen, that will generate phpickle_gen_read_ops.php and phpickle_gen_write_ops.php

To debug unpickling, call phpickle_unpickler->set_debug(true) and in the read
handler code, just to if ($debug). In the handler code, you can read data from the
$stream, using phpickle_stream methods and push results into $stack that is a
phpickle_stack instance. $memo is for memorizing things.
```

###  Health Score

20

—

LowBetter than 14% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity43

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

991d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/01ce72cfc82f990e584f7433537ea0b82eadd83715466f9e57c8d2d0b717bf9b?d=identicon)[Dale08](/maintainers/Dale08)

---

Top Contributors

[![terryf](https://avatars.githubusercontent.com/u/164401?v=4)](https://github.com/terryf "terryf (11 commits)")

### Embed Badge

![Health badge](/badges/dale-phpickle/health.svg)

```
[![Health](https://phpackages.com/badges/dale-phpickle/health.svg)](https://phpackages.com/packages/dale-phpickle)
```

###  Alternatives

[mtdowling/jmespath.php

Declaratively specify how to extract elements from a JSON document

2.0k472.8M135](/packages/mtdowling-jmespathphp)[opis/closure

A library that can be used to serialize closures (anonymous functions) and arbitrary data.

2.6k230.0M284](/packages/opis-closure)[masterminds/html5

An HTML5 parser and serializer.

1.8k242.8M229](/packages/masterminds-html5)[sabberworm/php-css-parser

Parser for CSS Files written in PHP

1.8k191.2M65](/packages/sabberworm-php-css-parser)[michelf/php-markdown

PHP Markdown

3.5k52.4M345](/packages/michelf-php-markdown)[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
