wendelladriel/laravel-validated-dto
Validated DTOs for Laravel: extend ValidatedDTO, declare typed properties and validation rules, and get validated, cast, type-safe data objects from request payloads. Includes built-in casts and config publishing for cleaner controllers.
Architecture fit. The package slots cleanly into Laravel's existing validation pipeline rather than competing with it. DTOs extend ValidatedDTO, declare typed properties, and supply rules(), defaults(), and casts() — all of which are Laravel-native concepts (rules, Validator, Sometimes, Password, etc.). Construction is polymorphic (fromArray, fromRequest, fromJson, from Eloquent models, from artisan input), and the container can resolve DTOs directly into controller actions. For teams already using Laravel's form requests or manual validation, this is an additive, low-ceremony refactor path. It is a thin abstraction over illuminate/validation, not a new validation engine, which is exactly the right architectural posture for a utility package.
Integration feasibility. Very high. composer require wendelladriel/laravel-validated-dto, optional config publish, and adoption can be scoped to a single feature. No database migrations, no service provider conflicts, no queue/event surface. Because the DTO is resolved from the current request via the container, it can replace form requests without rewriting controllers. Casting (StringCast, BooleanCast, enum/Carbon handling) is where most of the value lands — it normalizes HTTP input into typed domain objects at the boundary.
Technical risk.
SkipOnTransform attribute, after hook, changed buildDataForExport visibility, JSON-serializable fixes). Semantic-version discipline looks reasonable on major bumps, but minor releases have changed behavior around casting and transformation more than once (e.g., empty-string number casts, timezone-preserving Carbon).rules(), casts(), and declared properties can fail at runtime rather than at static analysis time.sometimes, file uploads, and nested DTOs inherits Laravel's quirks — generally fine, but worth pinning with tests.Key questions for the maintainer/team.
SECURITY.md existence?casts()/defaults() behavior changes in minor releases?Stack fit. Best fit is a PHP 8.1+ Laravel application (10/11/12/13 supported per release notes) that already leans on Laravel validation and has, or wants, a typed boundary between HTTP and domain layers. It fits poorly in codebases that deliberately avoid reflection-heavy patterns or that need DTO serialization beyond Laravel's toArray/JSON conventions.
Migration path. Do not attempt a big-bang replacement of form requests. Recommended path:
$request->validate(...) and form requests in that area with DTOs.casts() usage, one DTO per operation) before expanding.Compatibility.
illuminate/validation and container.Arrayable and JSON serialization are supported, which matters for API responses and nested structures.^4.x and lock the exact version; track releases for behavior-affecting minors.Sequencing.
Maintenance. Low ongoing cost by design — no runtime services, no schema, no background jobs. The real maintenance burden is version tracking: each Laravel major requires a compatible package release, and each package minor may alter casting/transformation behavior. Mitigate with a pinned version, a standing upgrade ticket per Laravel cycle, and a small internal test suite around DTO construction and error shapes.
Support. Community-supported only. There is no commercial backing, no guaranteed response time, and a single primary maintainer. Operationally this means the adopting team must own the abstraction: designate an internal owner, keep a documented convention guide, and be prepared to fork or vendor the package if upstream stalls. The MIT license makes forking viable and low-risk legally.
Scaling. Runtime overhead is negligible — DTO construction is reflection plus a Validator call, which is the same order of cost as a form request. Validation happens at the boundary, so it scales the same way the framework does. The scaling risk is organizational, not technical: DTO proliferation (one class per endpoint variant) can create a maintenance surface that grows faster than the value delivered. Enforce conventions early and consider shared base DTOs for common shapes.
Failure modes.
ValidationException — consistent with Laravel, but if the existing API does not use Laravel's error format, response contracts can shift. Test error payloads explicitly.rules()/casts() or vice versa can produce confusing missing-property or type errors at runtime.Ramp-up. High developer fluency with Laravel validation transfers directly; learning cost is measured in hours, not days. The main onboarding investment is convention-setting (naming, casting policy, when to use DTOs vs. form requests), which is a team-lead responsibility, not a training program. Plan for a short internal demo plus a written convention doc, and expect productive output within the first sprint for developers already comfortable with Laravel.
TPM verdict. A well-scoped, low-risk utility with clear ergonomic upside and a modest, honest risk profile dominated by single-maintainer concentration and thin public adoption evidence. Approve for scoped adoption with pinned versions, an internal owner, and a documented fork contingency — not as foundational infrastructure.
How can I help you explore Laravel packages today?