PHP Serialize Objects & Serialize Magic Methods - Full PHP 8 Tutorial

Поділитися
Вставка
  • Опубліковано 18 вер 2024

КОМЕНТАРІ • 76

  • @dragonlax9405
    @dragonlax9405 2 роки тому +47

    This course is a blessing, it should be added to the official "php the right way page" !

  • @DanThemes
    @DanThemes 2 роки тому +8

    It's been said over and over again, but I have to say it too: This entire course is simply outstanding in every way. I had a pretty complex idea of a PHP project in my head for many years, and now, after reaching this far through the course, I find that project idea not only doable, but also embarrassingly easy. Thank you for the time and effort put in these videos!

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому +1

      I'm so glad to hear that, thank you 🙏

  • @karam0101
    @karam0101 2 роки тому +5

    The best PHP course ever, thanks a million

  • @Vitalii-m6r
    @Vitalii-m6r Рік тому +1

    Thank you for explaining the difference between Serialize, Sleep, Unserialize, and Wakeup magic methods.

  • @invgreat5608
    @invgreat5608 Рік тому +3

    Best php tutorial!

  • @edwardai209
    @edwardai209 2 роки тому +5

    Impressive and good explanation on serialization in PHP.
    Thanks you again Gio.

  • @jephthahefereyan7431
    @jephthahefereyan7431 2 роки тому +6

    Really wonderful course. Thanks. Having a lesson on deep vs shallow cloning will be nice.

  • @federicobau8651
    @federicobau8651 2 роки тому +5

    Good video, and very helpful, surely needed to be watched several times or come back for a refresh if needed to serialize in some project. Great that you've created this course really.

  • @dancingdev1088
    @dancingdev1088 2 роки тому +2

    Love all your videos. Keep posting. You don't know how strong you are making the newbies and existing devs like me

  • @JohnnyBigodes
    @JohnnyBigodes 3 роки тому +2

    Another great lesson and I learned that the serialize and unserialize methods will be deprecated... Didnt know that and I use that methods extensively.

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +1

      Thank you, glad it was helpful. Yea I used Serializable interface as well, had to replace with serialize/unserialize magic methods

  • @faramarztayyari3734
    @faramarztayyari3734 2 роки тому +2

    thank you for the time and effort

  • @superheroshortss
    @superheroshortss 9 місяців тому

    So far great. One more thing to add, if you specify which property to include in serialization using __sleep method so when you unserialize it, the property that was not included in the sleep method would be set to NULL

  • @ifetmartinovic
    @ifetmartinovic 6 місяців тому

    Fantastican kurs, sve je odlicno objasnjeno. Resio si mi puno dilema :D

  • @supermonkey4324
    @supermonkey4324 Рік тому

    The amount of work you provided to us is incredible, the quality of the course is amazing. It's crystal clear and perfectly balanced. Thank you for existing

  • @2008rol
    @2008rol 2 роки тому +1

    Good tutorial. I would appreciate you could tell more about why and when we need to use serialization. I seldom serialize an object, therefore would like to know the situation we need to serialize.

    • @ProgramWithGio
      @ProgramWithGio  2 роки тому +2

      Thank you. You would use serialization when you need to pass around objects or save an object & revive it later and use it like in queued jobs for example

  • @user-mo3cw6go7c
    @user-mo3cw6go7c Рік тому

    This was completely new to me. Thank you!

  • @Zubbee
    @Zubbee 2 роки тому

    Great lesson, first time exposure to serialize and unserialize. I certainly would have to come back here especially as I come across more code. Thanks Gio.

  • @zubair.mohsin
    @zubair.mohsin 3 роки тому +2

    Great work Gio. Really helpful.

  • @ragadiveluka
    @ragadiveluka 2 роки тому +1

    Great course and great teacher!!

  • @MaxSongLine
    @MaxSongLine 2 роки тому

    Thanks a lot!!!! Such a great Tutorial!!!

  • @christiansosa5484
    @christiansosa5484 Рік тому

    Amazing work dude

  • @bevedel
    @bevedel 2 роки тому

    Awesome! Thank you so much. waiting for more content specially about deep and shallow object copying.

  • @OFabianoSilva
    @OFabianoSilva 2 роки тому +1

    Super!

  • @FranciscoJunior29
    @FranciscoJunior29 2 роки тому

    Good job man, thanks for share.

  • @user-bf5sb1fs1w
    @user-bf5sb1fs1w 2 роки тому +1

    Thank you SO MUCH!!!

  • @naumanbashir6385
    @naumanbashir6385 2 роки тому +1

    Looking forward to deep and shallow coping

  • @godmansarah
    @godmansarah 2 роки тому

    Very clear, thanks!

  • @ryanford516
    @ryanford516 Рік тому

    Thank you for the upload, Gio! Gonna keep pestering you with questions though :) You say that serialization is the process of converting a value into a string form but towards the end of the video you made the __serialize method to turn the object into an array. So can you really rely on arrays for storing or transmitting data?

    • @ProgramWithGio
      @ProgramWithGio  Рік тому

      No problem, keep asking the questions. Serialize magic method must return an array of key value pair which is what gets serialized. So it's a flexible way to tell PHP how to serialize an object & what data to serialize. The end result is still a serialized string, the array just provides the structure.

  • @memack101
    @memack101 2 роки тому

    Thank you.

  • @ilya_123__
    @ilya_123__ 9 місяців тому

    thank you !

  • @hasnatsafder7463
    @hasnatsafder7463 5 місяців тому

    Excellent video. I have two questions.
    1- Why is serialize not used more commonly. We most often use JSON now to e.g. store data in database and then convert that to associative arrays or DTOs when fetching from database. Do you have a case where we should serialize?
    2- The __sleep and __wakeup methods seem redundant to me. I can see myself always using __serialize and __serialize methods. What do you think?

    • @ProgramWithGio
      @ProgramWithGio  5 місяців тому

      Thank you.
      1. serialize can serialize objects. If you are not serializing objects or complex structures then json is much simpler & better way to stringify it.
      2. serialize/unserialize magic methods were introduced in 7.4. So yes I would stick to using serialize/unserialize magic methods. You can read more about it in the RFC: wiki.php.net/rfc/custom_object_serialization

  • @dawid_dahl
    @dawid_dahl 3 роки тому +1

    When to use JSON serialization and when to use the serialize/unserialize php functions? When you need to use the magic hooks?

    • @ProgramWithGio
      @ProgramWithGio  3 роки тому +1

      If you need to serialize objects you would use serialize function. You can use magic methods to handle serialization and unserialization

  • @loznicafk
    @loznicafk 3 роки тому +1

    nice, keep up the good work :)

  • @hamada_emam
    @hamada_emam Рік тому

    thanks

  • @parijke
    @parijke 3 роки тому +1

    Very cool

  • @quoctrieu2413
    @quoctrieu2413 10 місяців тому

    i try to serialize an url and pass it as an argument in another url. When i unserialize i got this error "unserialize(): Error at offset 344 of 519 bytes". Can you please explain ? Thanks !

  • @benderbg
    @benderbg Місяць тому

    One comment for the UA-cam's magic algorithms.