Skip to content
Use PHP's serialization methods from Ruby.
Latest commit 3b334d1 May 24, 2016 @jqr Merge pull request #13 from nehresma/jruby-fix
Fix warning from JRuby
Failed to load latest commit information.
lib Fix warning from JRuby May 24, 2016
.gitignore Initial import. Jun 18, 2009 adding README markdown Oct 24, 2012
php-serialize.gemspec Initial import. Jun 19, 2009

Ruby PHP Serializer

This module provides two methods: PHP.serialize() and PHP.unserialize(), both of which should be compatible with the similarly named functions in PHP.

Basic usage:

require 'php_serialize'
PHP.serialize({'foo' => 'bar'}) #=> "a:1:{s:3:\"foo\";s:3:\"bar\";}"
PHP.unserialize('a:1:{s:3:"foo";s:3:"bar";}') #=> {"foo"=>"bar"}

PHP.unserialize can also read PHP sessions, which are collections of named serialized objects. These can be reserialized using PHP.serialize_session(), which has the same semantics as PHP.serialize(), but which only supports Hash and associative Arrays for the root object.


TJ Vanderpoel, initial PHP serialized session support.

Philip Hallstrom, fix for self-generated Structs on unserialization.

Edward Speyer, fix for assoc serialization in nested structures.

Author: Thomas Hurst, WWW:

Something went wrong with that request. Please try again.