laravel-dtos

Create Spatie Laravel Data DTOs with nested structures, formatters, and test factories.

Updated Apr 7, 2026
One-click install
npx skills add https://github.com/Sivanwol/sabo-platfom --skill laravel-dtos-sivanwol
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: laravel-dtos
Source: https://github.com/Sivanwol/sabo-platfom/tree/main/.ai/skills/laravel-dtos
Command: npx skills add https://github.com/Sivanwol/sabo-platfom --skill laravel-dtos-sivanwol

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

Data flows in Laravel apps are often ad hoc and error-prone. DTOs provide a typed, explicit contract for input and output, enabling safer data handling and easier testing across layers.

Core Features & Use Cases

  • Constructor property promotion for clear, type-rich DTOs.
  • Nested DTOs, formatters, and transformers to map and validate data between boundaries.
  • Test factories integration via HasTestFactory to hydrate DTOs in tests.
  • Clear strategies for API requests/responses, model casts, and data transformations.

Quick Start

Create a DTO from input using CreateOrderData::from() or a transformer to produce a structured DTO ready for business logic.

Frequently Asked Questions about laravel-dtos

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I standardize and validate data flow in Laravel apps?

You can standardize Laravel data flow using typed Data Transfer Objects. DTOs provide a typed, explicit contract for input and output, enabling safer data handling and easier testing across application layers.

What is the best way to structure nested data for Laravel API requests and responses?

The best way to structure nested data for Laravel API requests and responses is using nested DTOs with formatters and transformers. This maps and validates data between system boundaries clearly.

How do I hydrate DTOs during testing in Laravel?

You hydrate DTOs during testing in Laravel by integrating test factories. Utilities like HasTestFactory scaffold and populate DTOs, ensuring structured test data for your validation logic.

Can I use constructor property promotion when defining DTOs in Laravel?

Yes, you can use constructor property promotion when defining DTOs in Laravel. This feature allows you to create clear, type-rich DTOs that enforce strict data contracts for your application.

Does this DTO approach work with Spatie Laravel Data?

Yes, this DTO approach works directly with Spatie Laravel Data. It leverages Spatie to build DTOs that apply core patterns like static from* factories and transformers for data mapping.