# Unmarshal object with PHP

**URL:** <https://www.ruby-forum.com/t/unmarshal-object-with-php/112479>\
**Category:** Ruby\
**Created:** [August 20, 2007, 1:26am UTC](https://www.ruby-forum.com/t/unmarshal-object-with-php/112479 "2007-08-20T01:26:21Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 20, 2007, 1:26am UTC](https://www.ruby-forum.com/t/unmarshal-object-with-php/112479/1 "2007-08-20T01:26:21Z")

</div>

Hi,

Is there any implamentation of something like Marshal.dump in PHP? Or  
any implementation that is easily readable, so I could rewrite it into  
PHP? 🙂 (I can’t figure out what’s going on in C files from ruby  
core 😉

Thanks,  
Peter

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 20, 2007, 1:33am UTC](https://www.ruby-forum.com/t/unmarshal-object-with-php/112479/2 "2007-08-20T01:33:21Z")

</div>

On 8/20/07, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> Hi,
> 
> Is there any implamentation of something like Marshal.dump in PHP? Or  
> any implementation that is easily readable, so I could rewrite it into  
> PHP? 🙂 (I can’t figure out what’s going on in C files from ruby  
> core 😉

What you need to figure out (or what you might need to tell us) is if  
you  
mean you want to do some cross-language serialization based on Marshal,  
or  
if you’re just looking for a PHP _equivalent_ of Marshal (but not  
necessarily cross language compatible). Given the topic of this list,  
I’ll  
assume the former for now! Someone else might be able to help with an  
implementation, but otherwise you might find this rather useful:

[http://redhanded.hobix.com/inspect/theMarshWalker.html](http://redhanded.hobix.com/inspect/theMarshWalker.html)

Cheers,  
Peter C.

> **[Ruby Inside: The Ruby Blog](http://www.rubyinside.com/)**
>
> The biggest Ruby and Rails blog since 2006 - tutorials, news, and lots more

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 20, 2007, 3:31am UTC](https://www.ruby-forum.com/t/unmarshal-object-with-php/112479/3 "2007-08-20T03:31:26Z")

</div>

On Aug 19, 2007, at 16:24, removed\_email\_address@domain.invalid wrote:

> Is there any implamentation of something like Marshal.dump in PHP? Or  
> any implementation that is easily readable, so I could rewrite it into  
> PHP? 🙂 (I can’t figure out what’s going on in C files from ruby  
> core 😉

[http://www.aagh.net/projects/ruby-php-serialize](http://www.aagh.net/projects/ruby-php-serialize)

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 20, 2007, 8:56am UTC](https://www.ruby-forum.com/t/unmarshal-object-with-php/112479/4 "2007-08-20T08:56:51Z")

</div>

2007/8/20, removed\_email\_address@domain.invalid [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid):

> Hi,
> 
> Is there any implamentation of something like Marshal.dump in PHP? Or  
> any implementation that is easily readable, so I could rewrite it into  
> PHP? 🙂 (I can’t figure out what’s going on in C files from ruby  
> core 😉

If you can switch formats, YAML might be easier:

[http://www.google.com/search?q=yaml+php](http://www.google.com/search?q=yaml+php)

Kind regards

robert

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 20, 2007, 9:55pm UTC](https://www.ruby-forum.com/t/unmarshal-object-with-php/112479/5 "2007-08-20T21:55:17Z")

</div>

On Aug 20, 2007, at 05:45, Piotr Sarnacki wrote:

> application to find out if user is logged in.
> 
> If there is no easy way to do this I’d have to change session  
> behaviour a little bit… :]

That’s probably optimal. Porting Ruby’s marshal format to PHP is  
going to take you longer than using PHP serialize instead of marshal  
on your session data.

---

<div class="post-metadata">

**Author:** ![casper\_the\_ghost](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/c/58956e/32.png) [@casper\_the\_ghost](https://www.ruby-forum.com/u/casper_the_ghost)\
**Post date:** [August 20, 2007, 2:48pm UTC](https://www.ruby-forum.com/t/unmarshal-object-with-php/112479/6 "2007-08-20T14:48:06Z")

</div>

Thanks for replies 🙂

On Aug 20, 3:30 am, Eric H. [removed\_email\_address@domain.invalid](mailto:removed_email_address@domain.invalid) wrote:

> [http://www.aagh.net/projects/ruby-php-serialize](http://www.aagh.net/projects/ruby-php-serialize)

I should specify more precisely 🙂 I need something like Ruby PHP  
serializer, but “the other way”. (PHP Ruby Marshalizer? 😉 )

Session data in Rails is marshaled and I want to read it in PHP  
application to find out if user is logged in.

> If you can switch formats, YAML might be easier:

Yes, YAML would be much easier 🙂 But as you see I can’t use it.

If there is no easy way to do this I’d have to change session  
behaviour a little bit… :]
