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

Dto Laravel Package

codememory/dto

Auto-hydrate PHP/Symfony DTOs from request/array data using rules and decorators. Supports name conversion (e.g., snake_case), enum casting via attributes, and event hooks during processing. Build a manager with caching and reflection for fast mapping.

View on GitHub
Deep Wiki
Context7

Product Decisions This Supports

  • Standardizing Data Transfer Objects (DTOs): Enables consistent DTO patterns across PHP/Laravel applications, reducing boilerplate and improving maintainability.
  • Validation Integration: Supports seamless integration with Symfony’s validation system (or custom validation logic) via decorators, aligning with enterprise-grade validation needs.
  • Type Safety & Enums: Facilitates automatic conversion of input data to enums or typed properties, reducing runtime errors and improving API robustness.
  • Event-Driven Customization: Allows for extensibility via events (e.g., pre/post-processing hooks), enabling custom business logic without modifying core DTO logic.
  • Build vs. Buy: Justifies buying this lightweight package over building a custom solution for teams needing DTOs with validation, type conversion, and extensibility.
  • API/Backend Services: Ideal for APIs where input sanitization, validation, and type conversion are critical (e.g., microservices, SaaS platforms).
  • Legacy System Modernization: Helps migrate older PHP systems to structured DTOs with minimal refactoring.

When to Consider This Package

  • Avoid if:
    • Your project already uses a mature DTO library (e.g., Spatie’s Laravel Data, API Platform’s DTO, or Symfony’s Serializer).
    • You need optional parameters or partial object hydration (this package requires all keys to exist).
    • Your team lacks PHP/Symfony familiarity (steep learning curve for decorators/events).
    • You prioritize performance over flexibility (this adds reflection overhead).
    • You’re in a Laravel-first project without Symfony dependencies (though native PHP support exists, Symfony integration is primary).
  • Consider alternatives:
    • Laravel-specific: Use spatie/laravel-data for Laravel-native DTOs.
    • Validation-heavy: Use Symfony’s Validator Component + manual mapping if decorators feel overkill.
    • Minimalism: Use PHP 8.1+ construct property promotion + manual validation for simpler cases.

How to Pitch It (Stakeholders)

For Executives:

"This package lets us standardize how data flows into our PHP/Laravel services—automatically converting inputs to typed objects (e.g., enums, validated strings) with zero manual mapping. It’s like a ‘smart parser’ for APIs or forms, reducing bugs from invalid data while keeping our code clean. Think of it as a safety net for our backend: no more runtime errors from malformed inputs. The Symfony integration aligns with our validation stack, and the event system lets us plug in custom rules later. It’s a lightweight investment to future-proof our data layer."

For Engineers:

*"codememory/dto gives us a battle-tested way to handle DTOs with:

  • Automatic type conversion (e.g., snake_case → camelCase, strings → enums).
  • Symfony validation baked in via decorators (no more scattered @Assert annotations).
  • Extensibility through events (e.g., validate before setting properties).
  • Native PHP support (though Symfony is first-class).

Tradeoffs:

  • Requires upfront setup (manager configuration, decorators).
  • No optional fields—validate inputs before hydrating.
  • Reflection overhead (but negligible for most use cases).

Use cases:

  • API request/response objects.
  • Form submissions with complex validation.
  • Microservices where input contracts matter.

Alternatives: If we’re Laravel-only, spatie/laravel-data might be simpler. But this gives us more control for Symfony-heavy stacks."*

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.
terminal42/code-quality-tools
codifyo/ts-generator-bundle
testo/fiber
mintobit/jobqueue
a4sex/maintenance-bundle
a4sex/entity-date-update
a4sex/client-identifier
a4sex/base-utilites
a4sex/key-value-storage
a4sex/micro-status
chilldev/dependency-injection-extra
datinglibre/datinglibre-app-api
biberltd/corebundle
bricre/symfony-bundle-test
biberltd/logbundle
dominium/http-adapter-bundle
dominium/google-analytics
a4sex/auto-clean-entity
christhompsontldr/laravel-inky
spatie/mailcoach-vapor