Be part of JetBrains PHPverse 2026 on June 9 – a free online event bringing PHP devs worldwide together.

ibtdi.com's avatar

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 .

0 likes
4 replies
abd_wazzan's avatar

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.

3 likes
Thavarajan's avatar

Is Laravel-data is a extended version of spatie-dto?, Is all the features are available in Laravel-data

1 like
kalvinmizzi's avatar

Laravel data is the new package. Data transfer object is deprecated

Laravel data is pretty cool. Spatie gave a great talk about it towards the end of Laracon summer online

Please or to participate in this conversation.