dto

Create immutable PHP DTOs with a fromArray factory for typed data transfer.

3|Updated Feb 13, 2026
One-click install
npx skills add https://github.com/codebar-ag/coding-guidelines --skill dto
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: dto
Source: https://github.com/codebar-ag/coding-guidelines/tree/main/resources/boost/skills/dto
Command: npx skills add https://github.com/codebar-ag/coding-guidelines --skill dto

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

Readonly data containers with a fromArray factory method to pass structured data between application layers, especially for external API responses and service boundaries.

Core Features & Use Cases

  • Immutable, strongly-typed data objects with a fromArray(array $data): static factory
  • Supports mapping varying API field names (PascalCase, camelCase, snake_case) to properties
  • Keeps business logic out of data containers, ensuring clean data transfer across layers

Quick Start

Create a new readonly class representing a DTO with public properties and a static fromArray method to instantiate it from an API response.

Frequently Asked Questions about dto

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

FAQPage Schema
How do I create immutable DTOs in Laravel for API responses?

Immutable DTOs in Laravel use readonly classes with public properties and a static fromArray method to map API response data into strongly-typed containers.

What is the best way to map varying API field names to DTO properties in PHP?

Mapping varying API field names to DTO properties in PHP is handled by the fromArray factory method, which normalizes PascalCase, camelCase, and snake_case inputs into typed properties.

How do I transfer structured data between Laravel application layers without leaking business logic?

Transferring structured data between Laravel layers cleanly uses immutable readonly DTOs, ensuring data carriers contain no business logic so boundaries remain strictly separated.

Does this approach to data transfer objects require readonly classes in PHP?

Yes, this approach to data transfer objects requires readonly classes in PHP to enforce immutability, alongside explicit property types and a fromArray factory for safe instantiation.

When should I use a fromArray factory method instead of a standard constructor for data transfer objects?

A fromArray factory method is used for data transfer objects when instantiating from external API arrays, keeping the standard constructor strictly typed and free of mapping logic.

Why keep business logic out of Laravel DTOs?

Keeping business logic out of Laravel DTOs ensures they remain pure immutable data carriers, preventing side effects and maintaining strict boundaries for data transfer across application layers.