Skip to main content

Posts

Showing posts with the label Data Transfer Object V3 Modernizes DTOs With PHP 8 Features

Data Transfer Object V3 Modernizes DTOs With PHP 8 Features

Spatie's Data Transfer Object (DTO) package makes constructing objects from arrays a breeze, giving you confidence in the data contained therein. I've been a fan of this package since learning about the initial V1 release, and I hope you'll consider this package for passing around data in your application. The DTO package just released V3 with all of the PHP 8 goodies we've only dreamed of up to this point. For those just starting to use or consider PHP 8 in your projects, the source code of the V3 DTO package is an excellent resource with real-world examples of helpful PHP 8 features. I want to congratulate the principal author Brent Roose and Spatie for moving forward with this excellent package with the features in the V3 release. Here are some of the main features taken from the readme available in V3: Named arguments Value Casts - convert properties typed as a DTO from array data to the DTO instance automatically Custom Casts - you can build your custom caster clas