laravel-data as mentioned in the documentation, can be used as a form request, API transformer, and other representations which means as I think you can most likely use it in your application code.
whereas data-transfer-object is used to construct objects from arrays of (serialized) data, which is if you are using DDD is more likely used in your domain code to represent your domain data.
you can still use laravel-data in your domain code also but you will have more functionality than you need.
Feb 9, 2022
4
Level 15
data-transfer-object vs laravel-data
Spatie has two packages
data-transfer-object : https://github.com/spatie/data-transfer-object laravel-data: https://github.com/spatie/laravel-data
seems the same for me, used them to make DTOs, etc but i'm not sure why spatie would create similar packages ? when do i pick one of them over the other one ? and both seems to still be supported !
Just want to make sure i'm using the right one for me .
Please or to participate in this conversation.