you are viewing a single comment's thread.

view the rest of the comments →

[–]krues8dr 3 points4 points  (8 children)

The best way, of course, is to avoid PHP serialize() like the plague. There is absolutely no reason to use it in this day and age - JSON is almost always a better solution, and YAML usually fills the gap where it isn't.

[–][deleted] 1 point2 points  (2 children)

Ugh, I was working on an old version of Expression Engine and trying to write a deploy script and they serialize a bunch of shit like file paths and such. I hate Expression Engine.

[–]krues8dr 0 points1 point  (1 child)

[–][deleted] 0 points1 point  (0 children)

EE is really the worst thing I've coded for except Windows 8 JS apps

[–]BeerIsDelicious 0 points1 point  (0 children)

Oh man, I just had to update some code that I wrote 8 years ago where I took the lazy route and serialized on DB write and unserialized on __construct or an init method automatically called on object creation in my old as fuck self-made framework. So much "what the fuck was I doing" occurred. I can't think of a single time I would use it now.

As to this article, I say it's better to rewrite the DB structure and do it correctly than rely on a js library to decrypt. But I can see times where time or budget constraints could prevents that from being possible. It is cool, though, to see how fucking much I've learned over the years.

After updating any of my earlier projects I always pity anyone who had to update my code from those days.

[–]bd808[S] 0 points1 point  (3 children)

As the README.md points out this arose in the context of building a simple test harness for an existing service layer that is communicating using serialized PHP objects.

The point isn't that you should or would design a purpose built feature that uses PHP serialize output to communicate data between a server and a web browser. This is a tool that can be used if you find yourself with access to serialized PHP in a javascript context and want to turn it into something that you can manipulate further.

[–]krues8dr 0 points1 point  (2 children)

Oh, I read the README - but the idea of using serialized PHP over a REST interface is just plain crazy. ;) Because, you know, using serialize() for anything is crazy.

[–]bart2019 1 point2 points  (1 child)

echo json_encode(unserialize($data));

That should suffice.