Data Transfer Objects - What Are DTOs - Full PHP 8 Tutorial

Поділитися
Вставка
  • Опубліковано 20 сер 2024
  • In this lesson, we learn about data transfer objects (DTO). We create a DTO object for the API classes we worked on in the last couple of lessons.
    SOME OF THE WAYS YOU CAN SUPPORT THE CHANNEL
    👍 Smash the like button
    🤝 Subscribe to the channel & turn the notifications on
    💬 Post comments, any feedback is greatly appreciated
    ⭐ Become a Patreon: / programwithgio
    THANK YOU!
    🛠️ TOOLS & SERVICES I USE
    Digital Ocean Hosting - Get 100$ credit - m.do.co/c/38b9...
    Domains on Namecheap - namecheap.pxf....
    Envato Elements - 1.envato.marke...
    LESSON 3.23
    Course Outline - github.com/gge...
    Course Playlist - • Learn PHP The Right Wa...
    RESOURCES
    Source Repo - github.com/gge...
    ** Affiliate Disclaimer: Some of the above links may be affiliate links, which may generate me a sales commission at no additional cost to you.

КОМЕНТАРІ • 91

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

    This seems like a very handy lesson. And this use case makes it real easy to understand. Thank you so much Gio. Moving on

  • @anonymizeratheist4885
    @anonymizeratheist4885 2 роки тому +12

    Great content as usual, always thought that DTO something not needed, now I see real case where is needed
    Thanks 👍

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

    Thank you for great tutorials,i have found you recently and got interested from the get go.

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

      Welcome to the channel :). Thank you, glad you liked it

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

    Man keep it up, you are doing a great job. Thank god I found you

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

    Great content. Is one of the best DTO tutorials I have seen. Thanks!

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

    Really a great content. waiting for your next video. Thanks

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

    Thanks again, Gio! Very interesting topic. You mentioned many times Factory class, can you please talk in details about the design patterns? You did great describing OOP, and I beleive it's a good time to talk about design patterns once you have the time.
    Best wishes,

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

      I'm thinking of making separate series for design patterns. Don't know if I'll cover it in this series since we are close to finish now. We'll see 👍

    • @KIKOmanasijev
      @KIKOmanasijev Рік тому +2

      ​@@ProgramWithGio Most of the tutorials are like 10 minutes short explanations of the Design Patterns themself. Having them in a format where you actually build/refactor (real world) larger apps would be terrific! So maybe a mini-series if you schedule allows it?

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

      @@KIKOmanasijev I'll think about it, thank you

  • @serhiicho
    @serhiicho Рік тому +1

    Awesome! Good explanation

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

    That is an excellent explanation. Thanks a lot!

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

    Great well explained video!
    Thanks for explaining such an architectural concepts :)

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

    Well Explained Gio!! Thank you

  • @user-vi2fp6dl7b
    @user-vi2fp6dl7b 4 місяці тому

    Thank you very much!

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

    What else can I say? Great content as always.

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

    Thanks. Also waiting for DDD ))

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

      I don't do much of DDD so I wouldn't feel comfortable teaching it yet.

  • @HadayatNiazi-xp1fz
    @HadayatNiazi-xp1fz Рік тому

    Great Job sir

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

    Amazing content

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

    Very Informative, keep the good work.

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

    Thank you so much for these great content. could you please introduce some resources or books about best practice architecture in software design? need more detail about service and repository layers. Thanks

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

      Thank you. Cant think of a book for such a thing currently, I would say check Laracasts series if you have subscription, they have a lot of valuable lessons.

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

    FIRST ! Love your content

  • @rxxt-sh1vj
    @rxxt-sh1vj 2 роки тому +1

    Can you also make a video on Middlewares ??

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

      I won't have a video dedicated to middlewares but will mention what it is in a video where I cover SlimPHP framework. Should be coming out soon 👍

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

    This is nice tip.
    I have been using a similar design pattern. My pattern is based on javabean from my java days.

  • @mathdothings
    @mathdothings 3 місяці тому

    Wonderful video. Do you use some Brave extension to improve errors and warnings on the browser?
    Thank you!

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

    Thank you.

  • @DavidSmith-ef4eh
    @DavidSmith-ef4eh 2 роки тому

    Cool stuff, now give the video on value objects and entities. I've been using them for quite a while, but still don't know what they are 🤣🤣

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

      Yup, next video will be about value objects. We covered entities already, you can check the playlist.

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

    Thanks for great video... can you please make another video on other use cases of DTO or other recently popular design system in laravel like DDD?

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

    I’m little bit confused… 7:16 you said that within the constructor just to pass params the object will know those values and properties and will return them inside the object?

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

      Not sure what you mean, we are instantiating a new DTO object & returning that, we pass the arguments to constructor. DTOs are typically immutable meaning that values on the properties shouldnt change once they are set/passed in constructor, thats why we set them to readonly & made them public because they cant be changed

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

      @@ProgramWithGio Constructor promotion, 20 years with PHP and didn’t catch this change 😀

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

    you can use resource to do this instead of DTO. i don't understand why use DTO

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

      This is a lesson about DTOs and what is its purpose. Also how would you set up a resource here?

  • @lottotred
    @lottotred 8 місяців тому

    Hey Gio! Great work!
    Does DTO can contain primitive data only or not? What's your opinion on that?

    • @genechristiansomoza4931
      @genechristiansomoza4931 8 місяців тому +1

      DTO can contain another DTO. Just Imagine that you are creating another data type.

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

      As @genechristiansomoza4931 said, you can have other DTOs within your DTO

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

    Basically a class of properties with a fancy name

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

      Sort of, but not exactly

    •  Місяць тому

      A readonly class of properties with a fancy name 😁

  • @firdavs.ibodullayev
    @firdavs.ibodullayev Рік тому

    can we say that DTO is the realization of Adapter pattern ?

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

      Not really, DTOs don't have any logic, they are dummy objects whose purpose is to transfer data.

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

    Finally!!!

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

    keep it up

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

    Would you mind making a deep dive into Livewire?

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

      I don't use Livewire so probably won't be making content on it anytime soon.

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

    How are you setting up the routes using a decorator??

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

      We set up the routes as we have always done in the series. Nothing special, just registering them in the public/index.php. You can check previews videos about routing to see how that's set up

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

    What's the difference between PDO and DTO?

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

      PDO is a data access object, it has database abstraction, DTO is a data transfer object. Two different things.

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

    I still dont see where this is better then having an array which can be defined or just a class with propertys.

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

      DTO is also a class with properties in a way. It's better than arrays in certain cases where you are accessing magical keys. API requests/responses are good candidates for DTOs or just even form requests that you pass to your model or service class.

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

    Can you please make a video on setting up a full fledged payment gateway in a website..using php?

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

    Is this course over? How many sections is left?

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

      Not over yet. This is the last section. Might make a fourth one for project, we'll see

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

      @@ProgramWithGio so this means that the advanced sections is over and there is no part 24 , right?

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

      @@roozbehsharifzadeh9157 not over yet, more videos will be published for this section.

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

    Hello, what does this mean:
    unexpected 'array' (T_ARRAY), expecting function (T_FUNCTION) or const (T_CONST):
    class Test {
    public array $data;
    }
    Error on the $data line.

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

      Check your PHP version, you are probably running 7.3 where type hints on properties are not allowed.

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

      @@ProgramWithGio I used 7.3 then I chooses in cpanel 7.4
      Now it works. But I have not 8.0 available lol

  • @drKatzman
    @drKatzman 2 місяці тому

    ConSHtruct, abSHtract

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

      English is my second language, so I do pronounce some things in a funny way sometimes :D

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

    excelent thanks! subscribe now