Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

TheFriendlyHacker's avatar

What does "serialize" mean?

I'm not quite sure if I completely understand what it means to "serialize" something in programming. What exactly does it mean? And how/when could I apply it to a Laravel app?

Thanks!

0 likes
2 replies
gregrobson's avatar

It's a way to store the values in an object into a text string format. A good introduction can be found here:

http://stackoverflow.com/questions/8641889/how-to-use-php-serialize-and-unserialize

Laravel does this in the background with jobs in queues. The job is a simple class with properties (could be name, email address, message, message ID etc) - you can't put the PHP class into the database as it is, but if you serialize it into a string you can.

When it get's unserialized you can turn it back into an object in PHP and access it's properties as you would any other PHP object.

It's similar to turning an object into JSON, but with the advantage that PHP will remember the native data type of each serialized item (string, array, integer, float, boolean).

Only properties get serialized - the methods will disappear when you unserialize.

5 likes

Please or to participate in this conversation.