filmov
tv
How to use data transfer objects (DTO) in Symfony API application

Показать описание
In this #PHP programming tutorial I explain how and why you should use data transfer objects (#DTO) for response in your #Symfony applications.
I demonstrate in real-life example how you can prepare your code to use DTOs. I also share some useful tips:
* how to separate data in DTO for customers and admins using serialization groups
* how to "turn off" processing of specific fields if they are not in use for current serialization group
* how to add virtual property into DTO
In this video I use Symfony 5 with PHP 7.4 but this tutorial is still relevant for older versions of Symfony framework or PHP.
⭐️ Final result you can find here ⭐️
⭐️ Support channel on Patreon ⭐️
⭐️ Resources ⭐️
🔗 Book O'Reilly "Head first design patterns"
Get € 20 on Hetzner Cloud hosting:
Register domain without hassle on GoDaddy
⭐️ TABLE OF CONTENT ⭐️
00:00:00 Introduction
00:02:00 Application structure
00:03:04 Define classes for DTOs
00:05:19 Create transformers
00:08:57 Using transformers in controllers
00:09:39 DTO without corresponding entity
00:11:46 Serialization groups
00:13:51 Improve performance
00:15:49 Virtual property
00:16:35 Transformer validation
I demonstrate in real-life example how you can prepare your code to use DTOs. I also share some useful tips:
* how to separate data in DTO for customers and admins using serialization groups
* how to "turn off" processing of specific fields if they are not in use for current serialization group
* how to add virtual property into DTO
In this video I use Symfony 5 with PHP 7.4 but this tutorial is still relevant for older versions of Symfony framework or PHP.
⭐️ Final result you can find here ⭐️
⭐️ Support channel on Patreon ⭐️
⭐️ Resources ⭐️
🔗 Book O'Reilly "Head first design patterns"
Get € 20 on Hetzner Cloud hosting:
Register domain without hassle on GoDaddy
⭐️ TABLE OF CONTENT ⭐️
00:00:00 Introduction
00:02:00 Application structure
00:03:04 Define classes for DTOs
00:05:19 Create transformers
00:08:57 Using transformers in controllers
00:09:39 DTO without corresponding entity
00:11:46 Serialization groups
00:13:51 Improve performance
00:15:49 Virtual property
00:16:35 Transformer validation
Комментарии