Thank you very very much for this tutorial. I started building API in symfony and found your channel recently. I find your videos very helpful on the subject. You are good at explaining things and showing real life examples. I hope there is more comming soon :). Thank you.
@CapCoding
4 жыл бұрын
Thank you very much for such a great feedback! Next tutorial more likely will be about docker. But I'm open for suggestions 🙂
@romansenyk2908
4 жыл бұрын
Hi There! Thank you for your informative videos. I’m rookie, trying to get into web development. Any chance you can compile some tutorials how to work with IDE like Docker and Symphony framework. It would help a lot! Thank you so much for your time! Keep up with the great work!
@CapCoding
4 жыл бұрын
Thanks Roman! Yes, sure. I'm currently preparing a tutorial how to configure Docker for Symfony project. Be in touch
@karolinaguaman1184
Жыл бұрын
Me sirvio mucho ....mill gracias . Lo gracioso del caso es que tuve un problema al final con el respond() y lo termine haciendo con un $this->json()
@MrWilde
2 жыл бұрын
Man I love this, there is a lack of more advanced programming methods used with PHP and Symfony. Thankyou for all your work, looking forward to watching more of your content
@CapCoding
2 жыл бұрын
Thank you, Robert! It means a lot for me. I’ll try to produce more advanced videos.
@GaryClarkeTech
2 жыл бұрын
Excellent..thank you!
@CapCoding
2 жыл бұрын
I’m glad that you like it
@renarsdilevka6573
3 жыл бұрын
What about using just models (business logic), entities(for persistence) and put serialization groups and the same asserts for validation and traits where class properties are repeated. So when returning data in response, you could just set serialization context? You did exactly that on your DTOs. I have seen projects where DTOs are present and each one of them drags in with class of builder (not in pattern sense)/factory, and i think that is an overkill. You use transformers for that in your video. If you get your serialization group right i think it is enough, for show, for listing, for mobile app. I got myself in the past, serialization groups and HATEOAs was so heavy, every time build objects and its dependencies three levels deep, this was time for DTO for the mobile application. It was a good solution for legacy. The same question goes for Request data mapped to Form, do we really need it. Would just use a model and validate that, no? Just a thought. I would be interested what do you think of it :)
@CapCoding
3 жыл бұрын
I would say that for small projects using models or entities with serialization groups would be more than enough. Probably DTOs also are not required when new version of API is introduced. It really depends in project/changes in API. At the same time I don't like to "mix" staff, f.e. using for response entities and DTOs. For me triggers to use DTO would be: * interfaces in API are different than entities/models * there are responses which combine data from different sources (f.e. some information from entity and some - from external service(s)) * there are no entities for response For processing request I'd use entity/model but not DTO. In 99% it works perfect. But at the same time I had situations when I had to use DTOs for request as well. Mainly it happened because of bad app design.
@renarsdilevka6573
3 жыл бұрын
@@CapCoding Thank you, i saw myself some other examples, like when you send mail and you need to replace mail template parameters, you could assemble DTO for that. And it is true if we want information gathered from multiple domain models and/or entities then DTO is a good choice. I do not know it is possible just have one DTO assembler, where you give an array of classes and array of extractable properties and it constructs you dynamically a DTO object. In my experience i have seen so far DTO assembler for each agregate model in the domain.
@CapCoding
3 жыл бұрын
@@renarsdilevka6573 So far I didn't see any dynamic assembler for DTO. Sounds like a good idea for a bundle ;)
@RealHomeboy
2 жыл бұрын
Thank you for sharing this. Very helpful! I’m trying this right now in a Laravel with Doctrine integration
@CapCoding
Жыл бұрын
Cool that you like it! Happy coding
@matiasnoriega1154
3 жыл бұрын
Excellent explanation, but I have a question: In the example controllers you always retrieve all objects, in case you wanted to have a method to fetch one particullar object (e.g. an Order, wich has more objects inside) how would you menage the Request (assuming is an json request)?
@CapCoding
3 жыл бұрын
Hi Matías! First of all thank you for a good feedback. I really appreciate it. In github you can check this DTO transformer which converts one object with dependencies (customer and products) into DTO The link to the transformer: github.com/Cap-Coding/symfony_api/blob/data_transfer_objects/src/Dto/Response/Transformer/OrderResponseDtoTransformer.php#L35 I hope it will help you
@pubsvm7355
3 жыл бұрын
Hey great tutorial, I just wanna know if it's possible to use DTO alongside NelmioApiDoc! I have used Groups for a month and two and had the benefit of Nelmio auto docing my controllers/endpoints using annotations, but now I want to use DTOs so I believe have to make the annotations a bit more specific which is a long path to go. any help?
@CapCoding
3 жыл бұрын
Hi there! I'm glad that you like this video. As I remember you can specify DTO using annotation "@SWG\Response" with "@Model". BTW you can also specify any FormType object as input for request
@pubsvm7355
3 жыл бұрын
@@CapCoding I'm receiving data through JSON so I think FormType doesn't provide any help for me. The `@Model` works just great thanks! this is a great tut & u r awesome. happily subscribed. I really needed a best practice source for Symfony.
@adrianfgutierrez2836
3 жыл бұрын
Very good. 0.5x for speed 😂
@null9842
Жыл бұрын
Very nice and informative. Thank you.
@CapCoding
Жыл бұрын
You’re welcome!
@Maruf-zt7dz
2 жыл бұрын
Isn't that add too much boilerplate code?
@CapCoding
2 жыл бұрын
It really depends on the service. For example, if you change a contract of your service, and all dependent services could be updated at the same time, you probably don’t need DTOs. But usually it’s not the case. It means that if you change the contract, you should release a new version of the endpoint and keep the previous one. That is why it’s easier to have this transfer layer which allows you to have as many different versions of endpoints (and maintenance is low)
@webdev723
3 жыл бұрын
Thank you this what I am looking for.
@CapCoding
3 жыл бұрын
Thanks, I'm glad to hear this 🙂
@genkazavr
3 жыл бұрын
Thank you for the lesson. I think it very useful.
@CapCoding
3 жыл бұрын
Thanks for the good feedback!
@TaiebBACCOUCH
3 жыл бұрын
Amazing work! Thanks man
@CapCoding
3 жыл бұрын
I'm glad that this video was useful for you
@auras97
3 жыл бұрын
Great job man. I really like your way of doing these videos. It is a little bit too fast or my taste, but nothing a 0.5 decrease in speed can't fix. Keep it up. Looking forward to more videos.
@CapCoding
3 жыл бұрын
Thanks! In new videos I've tried to explain slower. What do you think of the latest video? Is it still too quick?
@auras97
3 жыл бұрын
@@CapCoding I think it’s better in the latest one. But since you actually read these I would like to add one more comment regarding the videos. Not trying to be a hater, don’t want this to sound wrong. I think it would be good for the growth of the channel if in the future you would work a little on the speaking side of English. I think sometimes it can be hard to understand some of the words(not often). Again, just giving my opinion on what I see can be improved. Keep it up and thank you again for the content.
@CapCoding
3 жыл бұрын
@@auras97 I appreciate your feedback. I'll try to make improvements.
@godwin.k
3 жыл бұрын
How to create DTOs system for external API and fectch data ?
@CapCoding
3 жыл бұрын
Hi @Godwin! Basically you can do it the same way as described in the video: create DTO class and its transformer, inject transformer into required class and use it to convert object before sending data to external API.
@godwin.k
3 жыл бұрын
@@CapCoding Thanks for the quick answer, I'll try this.
@godwin.k
3 жыл бұрын
I try it like you but where did get the data of my external api or in which file did I going to put it (data) to effectively obtain all information. Did have an example of this case?
@CapCoding
3 жыл бұрын
@@godwin.k I didn't fully understand your question. Once you receive data from external API, you store it in the variable as object or array. Then you can persist data into DB or file. This logic is totally depends on your use-case. Feel free to join my telegram chat to discuss your problem t.me/capcodingchat
@ahmedesa6198
3 жыл бұрын
keep on good work
@CapCoding
3 жыл бұрын
I will try my best 🙂
@fixmedev521
3 жыл бұрын
Thanks!
@CapCoding
3 жыл бұрын
You are welcome!
@khusamalfas2121
2 жыл бұрын
Hello there, great video i love your logic in solve the issue
@CapCoding
2 жыл бұрын
Hi! Thank you 🙂
@Valantir007
3 жыл бұрын
findAll and then reset? WTF...?
@CapCoding
3 жыл бұрын
Not everybody understand this joke 😀
@Rofiqulislam-pi6ls
2 жыл бұрын
Nice
@CapCoding
2 жыл бұрын
Thanks!
@sergeypoprygin2670
3 жыл бұрын
Иван, я то думал, что ты как трушный программер растолкуешь, как делать dto трансформеры юзая Reflection, а ты все ручками сэтишь, еще и в публичные проперти ... пичаль тоска
@CapCoding
3 жыл бұрын
Кто такой Иван? Использовать Reflection в продакшен коде не рекомендуется и вам не советую
@sergeypoprygin2670
3 жыл бұрын
@@CapCoding да что ты говоришь? а руками сетить паблик атрибуты рекомендуется? все с тобой ясно, мастер инкапсуляции ты наш
@CapCoding
3 жыл бұрын
@@sergeypoprygin2670 Да, рекомендуется. DTO не содержит никакой логики и поэтому там нечего инкапсулировать. Как пример, можешь глянуть класс Request из Symfony. В нем $request, $query, $server и т.п. публичные свойства.
@sergeypoprygin2670
3 жыл бұрын
@@CapCodingахаха та даже в самой симфони используется Reflection в продакшене, в контроллерах к примеру, так что товарищ, учи теорию, а по поводу dto, можешь посмотреть, как реализован DTO в magento 2, и там все через Reflection, а логику, да, dto хранит только состояние, но логика должна находиться не с самом dto классе, а в transformer классах
@sergeypoprygin2670
3 жыл бұрын
@@CapCoding и кстати, знаешь почему скорее всего в Request те свойства публичные? потому что апи класса не менялся и не будет меняться вообще
Пікірлер: 57