# serialize extension objects?

- Thread: https://externals.io/message/17137
- Original archive: https://news-web.php.net/php.internals/17137
- Started by David Olsson on 2005-07-05T14:16:11+00:00
- Messages: 3
- Reply by email to internals@lists.php.net
- More for agents: search with https://externals.io/search.md?q={query} · JSON API at https://externals.io/api · documentation at https://externals.io/llms.txt

---

## #17137 — David Olsson — 2005-07-05T14:16:11+00:00

URL: https://externals.io/message/17137#17137

I'm writing an extension for PHP 4 (running version 4.3.10) in C/C++. 
The extension provides a set of classes to the PHP programmer (it is, 
hence, object oriented). My problem is that some of the objects (or, 
rather, references to objects) provided by my extension needs to be 
stored in a session and, thus, serialized. I have, however, no idea on 
how to provide a custom serialize function for my objects as the 
built-in one (for obvious reasons) doesn't work. I have had no luck 
finding any useful tips and/or documentation for PHP 4 regarding this 
matter. I sincerely hope that someone could point me in the right direction.

Or have I completely misunderstood the entire concept; when storing a 
reference to an object (implemented in C/C++), do the object really have 
to be serialized? Thanks for all tips! :-)

Best regards
David Olsson

---

## #17140 — Marcus Boerger — 2005-07-05T18:41:52+00:00

URL: https://externals.io/message/17137#17140 · In reply to: #17137

Hello David,

  wait for PHP 5.1 and use the Serializable interface. Otherwise ask
on the general list for support.

marcus

Tuesday, July 5, 2005, 4:16:11 PM, you wrote:

> I'm writing an extension for PHP 4 (running version 4.3.10) in C/C++. 
> The extension provides a set of classes to the PHP programmer (it is, 
> hence, object oriented). My problem is that some of the objects (or, 
> rather, references to objects) provided by my extension needs to be 
> stored in a session and, thus, serialized. I have, however, no idea on 
> how to provide a custom serialize function for my objects as the 
> built-in one (for obvious reasons) doesn't work. I have had no luck 
> finding any useful tips and/or documentation for PHP 4 regarding this 
> matter. I sincerely hope that someone could point me in the right direction.

> Or have I completely misunderstood the entire concept; when storing a 
> reference to an object (implemented in C/C++), do the object really have 
> to be serialized? Thanks for all tips! :-)

> Best regards
> David Olsson




-- 
Best regards,
 Marcus                            mailto:mail@marcus-boerger.de

---

## #17141 — Wez Furlong — 2005-07-05T18:48:39+00:00

URL: https://externals.io/message/17137#17141 · In reply to: #17140

I don't think the general list will help David write his extension :)

David, right now the only thing you can do is exactly the same as
classes you define in PHP scripts.  You can provide the magic sleep
and wakeup functions to do something more than just have your
properties copied and reinstated.

--Wez.



> Hello David,
> 
>   wait for PHP 5.1 and use the Serializable interface. Otherwise ask
> on the general list for support.
> 
> marcus
> 
> Tuesday, July 5, 2005, 4:16:11 PM, you wrote:
> 
> > […]
> 
> > […]
> 
> > […]
> 
> 
> 
> 
> --
> Best regards,
>  Marcus                            mailto:mail@marcus-boerger.de
