0.12
Low commit activity in last 3 years
A long-lived project that still receives updates
This module provides two methods: PHP.serialize() and PHP.unserialize(), both of which should be compatible with the similarly named functions in PHP. It can also serialize and unserialize PHP sessions.
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 1.15
~> 10.0
 Project Readme

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.

Installing

In your Gemfile:

gem "php-serialize"

Usage

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.

See http://php.net/serialize and http://php.net/unserialize for details on the PHP side of all this.

Acknowledgements

  • 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 tom@hur.st, http://hur.st/