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.
This seems like a very handy lesson. And this use case makes it real easy to understand. Thank you so much Gio. Moving on
Awesome, glad to hear. Thank you 🙌
Great content as usual, always thought that DTO something not needed, now I see real case where is needed
Thanks 👍
Glad it was useful, thank you 🙏
Exactly, same for me, what a great class
Thank you for great tutorials,i have found you recently and got interested from the get go.
Welcome to the channel :). Thank you, glad you liked it
Man keep it up, you are doing a great job. Thank god I found you
Thank you
Great content. Is one of the best DTO tutorials I have seen. Thanks!
Thank you 💙
Really a great content. waiting for your next video. Thanks
Thank you
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,
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 👍
@@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?
@@KIKOmanasijev I'll think about it, thank you
Awesome! Good explanation
Thank you 💙
That is an excellent explanation. Thanks a lot!
Glad it was helpful, thank you
Great well explained video!
Thanks for explaining such an architectural concepts :)
You're welcome $ thank you 🙌
Well Explained Gio!! Thank you
You're welcome, thank you
Thank you very much!
You're welcome!
What else can I say? Great content as always.
Thank you 💙
Thanks. Also waiting for DDD ))
I don't do much of DDD so I wouldn't feel comfortable teaching it yet.
Great Job sir
Thank you
Amazing content
Thank you 🙌
Very Informative, keep the good work.
Thanks a lot 💙
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
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.
FIRST ! Love your content
Thank you 🙌
Can you also make a video on Middlewares ??
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 👍
This is nice tip.
I have been using a similar design pattern. My pattern is based on javabean from my java days.
Thank you 💙
Wonderful video. Do you use some Brave extension to improve errors and warnings on the browser?
Thank you!
Thank you. No, I don't use extensions
Thank you.
You're welcome
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 🤣🤣
Yup, next video will be about value objects. We covered entities already, you can check the playlist.
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?
Thanks for the suggestion 👍
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?
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
@@ProgramWithGio Constructor promotion, 20 years with PHP and didn’t catch this change 😀
you can use resource to do this instead of DTO. i don't understand why use DTO
This is a lesson about DTOs and what is its purpose. Also how would you set up a resource here?
Hey Gio! Great work!
Does DTO can contain primitive data only or not? What's your opinion on that?
DTO can contain another DTO. Just Imagine that you are creating another data type.
As @genechristiansomoza4931 said, you can have other DTOs within your DTO
Basically a class of properties with a fancy name
Sort of, but not exactly
A readonly class of properties with a fancy name 😁
can we say that DTO is the realization of Adapter pattern ?
Not really, DTOs don't have any logic, they are dummy objects whose purpose is to transfer data.
Finally!!!
😎
keep it up
💙💙
Would you mind making a deep dive into Livewire?
I don't use Livewire so probably won't be making content on it anytime soon.
How are you setting up the routes using a decorator??
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
What's the difference between PDO and DTO?
PDO is a data access object, it has database abstraction, DTO is a data transfer object. Two different things.
I still dont see where this is better then having an array which can be defined or just a class with propertys.
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.
Can you please make a video on setting up a full fledged payment gateway in a website..using php?
Thanks for the suggestion, noted
Is this course over? How many sections is left?
Not over yet. This is the last section. Might make a fourth one for project, we'll see
@@ProgramWithGio so this means that the advanced sections is over and there is no part 24 , right?
@@roozbehsharifzadeh9157 not over yet, more videos will be published for this section.
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.
Check your PHP version, you are probably running 7.3 where type hints on properties are not allowed.
@@ProgramWithGio I used 7.3 then I chooses in cpanel 7.4
Now it works. But I have not 8.0 available lol
ConSHtruct, abSHtract
English is my second language, so I do pronounce some things in a funny way sometimes :D
excelent thanks! subscribe now
Thank you 💙