Weave 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

Laravel Castable Data Transfer Object Laravel Package

jessarcher/laravel-castable-data-transfer-object

A Laravel package that lets Eloquent models cast attributes directly to data transfer objects, keeping structured data typed and clean while handling JSON serialization automatically. Ideal for replacing loose arrays with explicit DTO classes.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Laravel 10 upgrade planning: v2.3.0 adds Laravel 10.x compatibility, removing this package as a blocker on the framework upgrade path. This is a roadmap enabler, not a feature change.
  • Build vs. buy on DTO casting: Confirms the package remains viable for teams that want typed data-transfer objects on Eloquent models instead of hand-rolled casts, array attributes, or ad-hoc validation. Renewed compatibility means "buy" stays the lower-maintenance choice for this narrow need.
  • Domain data integrity: Supports decisions to standardize on typed DTOs for API payloads, form-to-model flows, events, and queued jobs, reducing untyped array sprawl.
  • Dependency risk review: A minor release with only compatibility changes signals low churn; useful input when deciding whether to keep this in the critical path versus a convenience layer.

When to Consider This Package

  • Consider it when: you run Laravel 8–10, want to cast Eloquent attributes to DTOs, and already use or accept spatie/data-transfer-object as a dependency. It's a strong fit for teams enforcing strict typing at the model boundary.
  • Look elsewhere when:
    • You need validation logic embedded directly in the cast itself.
    • You're on Laravel 11+ — this release only extends support through 10.x, so forward compatibility is unproven.
    • Native custom casts, Attribute accessors/mutators, or Laravel's built-in AsArrayObject/AsCollection casts already cover the use case.
    • You want a package with a larger maintainer base; this remains a single-maintainer project, though the laravel-shift contribution slightly improves the bus factor.
    • DTOs carry heavy nested transformation or persistence logic — that's better handled in a dedicated layer.

How to Pitch It (Stakeholders)

  • For executives: Low-risk, narrowly scoped dependency update. It clears a Laravel 10 compatibility blocker and avoids funding custom casting code. No breaking changes; a minor version bump only adds framework support.
  • For engineering: Safe to upgrade from v2.2.x. The change is a compatibility patch contributed by laravel-shift, indicating ecosystem engagement. Adopt it to keep typed DTOs on models while proceeding with the Laravel 10 migration; revisit if the project stalls or Laravel 11 support lags.
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.
jinas/dhivatar
store-doc/laravel-storage-driver
plus-it/laravel-translation-manager
diephp/perhaps
diephp/telegraph
osmaviation/spreadsheet
microsoft/fluentui-system-icons
mmccook/php-json-canonicalization-scheme
middlewares/firewall
qubiqx/montapacking
nyoncode/laravel-package-console
pnscripts/filament-broadquill-lite
pnscripts/laravel-sentfold-lite
vleap/mx-sdk-laravel-internal
twidpay/utils
htetmyathlaing/scout-elasticsearch-driver
artisan-toolbox/front-awesome
ls/client-assistant
users-au/laravel-client
cgv/localized-resource