Weave Code
Code Weaver
Helps Laravel developers discover, compare, and choose open-source packages. See popularity, security, maintainers, and scores at a glance to make better decisions.
Feedback
Share your thoughts, report bugs, or suggest improvements.
Subject
Message

Data Transfer Object Laravel Package

spatie/data-transfer-object

PHP 8+ data transfer objects with “batteries included”: map and cast input arrays into typed DTOs, validate via attributes, and handle nested objects/collections. Note: package is deprecated; consider spatie/laravel-data or cuyz/valinor.

View on GitHub
Deep Wiki
Context7
3.9.1

What's Changed

New Contributors

Full Changelog: https://github.com/spatie/data-transfer-object/compare/3.9.0...3.9.1

3.9.0

What's Changed

New Contributors

Full Changelog: https://github.com/spatie/data-transfer-object/compare/3.8.1...3.9.0

2.8.4

What's Changed

New Contributors

Full Changelog: https://github.com/spatie/data-transfer-object/compare/2.8.3...2.8.4

3.7.2
  • #[Strict] is passed down the inheritance chain so children are strict when parent is strict (#239)
3.7.1
  • Cast properties with self or parent type (#236)
1.14.0
  • Support PHP ^8.0
3.7.0
  • Add #[MapTo] support (#233)
3.6.2
  • Correct behavior of Arr::forget with dot keys (#231)
3.6.1
  • Fix array assignment bug with strict dto's (#225)
3.6.0
  • Support mapped properties (#224)
3.5.0
  • Support union types in casters (#210)
3.4.0
  • Fix for an empty value being created when casting ArrayAccess objects (#216)
  • Add logic exception when attempting to cast ArrayAccess objects that are not traversable (#216)
  • Allow the ArrayCaster to retain values that are already instances of the itemType (#217)
3.3.0
  • Expose DTO and validation error array in ValidationException (#213)
3.2.0
  • Support generic casters (#199)
  • Add ArrayCaster
  • Add casting of objects that implement ArrayAccess to the ArrayCaster (#206)
  • Fix for caster subclass check (#204)
3.1.1
  • Make DefaultCast repeatable (#202)
3.1.0
  • Add DataTransferObject::clone(...$args)
3.0.4
  • Support union types (#185)
  • Resolve default cast from parent classes (#189)
  • Support default values (#191)
3.0.3
  • Fix when nested DTO have casted field (#178)
3.0.2
  • Allow valid DTOs to be passed to caster (#177)
3.0.1
3.0.0

This package now focuses only on object creation by adding easy-to-use casting and data validation functionality. All runtime type checks are gone in favour of the improved type system in PHP 8.

  • Require php:^8.0
  • Removed all runtime type checking functionality, you should use typed properties and a static analysis tool like Psalm or PhpStan
  • Removed Spatie\DataTransferObject\DataTransferObjectCollection
  • Removed Spatie\DataTransferObject\FlexibleDataTransferObject, all DTOs are now considered flexible
  • Removed runtime immutable DTOs, you should use static analysis instead
  • Added Spatie\DataTransferObject\Validator
  • Added Spatie\DataTransferObject\Validation\ValidationResult
  • Added #[DefaultCast]
  • Added #[CastWith]
  • Added Spatie\DataTransferObject\Caster
  • Added #[Strict]
2.8.3
  • Add support for using collection internally
2.8.2

This might be a breaking change but it was required for a bugfix

  • Prevent DataTransferObjectCollection from iterating over array copy (#166)
2.8.1
  • Fix for invalid return type #164
2.8.0
  • Allow the traversal of collections with string keys
2.7.0
Weaver

How can I help you explore Laravel packages today?

Conversation history is not saved when not logged in.
Prompt
Add packages to context
No packages found.
davejamesmiller/laravel-breadcrumbs
artisanry/parsedown
christhompsontldr/phpsdk
enqueue/dsn
bunny/bunny
enqueue/test
enqueue/null
enqueue/amqp-tools
milesj/emojibase
bower-asset/punycode
bower-asset/inputmask
bower-asset/jquery
bower-asset/yii2-pjax
laravel/nova
spatie/laravel-mailcoach
spatie/laravel-superseeder
laravel/liferaft
nst/json-test-suite
danielmiessler/sec-lists
jackalope/jackalope-transport