百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
L

laravel-validated-dto

> 后端框架
开源

用于 Laravel 应用程序的带验证的数据传输对象

773 stars0 点赞2 次浏览
访问官网GitHub

工具介绍

用于 Laravel 应用程序的带验证的数据传输对象

Installation

You can install the package via composer:

bash
composer require wendelladriel/laravel-validated-dto

You can publish the config file with:

bash
php artisan vendor:publish --tag="validated-dto"

Usage

Create a DTO by extending ValidatedDTO, declaring typed properties, and defining the validation rules for incoming data:

…

Create an instance from an array, request, JSON string, Eloquent model, or artisan command:

php
$dto = UserDTO::fromArray([
    'name' => 'John Doe',
    'email' => '[email protected]',
    'password' => 's3CreT!@1a2B',
]);

$dto->name; // John Doe
$dto->toArray();

You can also inject a DTO into a controller action and let the service container resolve it from the current request:

php
use Illuminate\Http\JsonResponse;

final class StoreUserController
{
    public function __invoke(UserDTO $dto): JsonResponse
    {
        return response()->json($dto->toArray());
    }
}

Access the full documentation here.

Changelog

Please see the changelog for more information on what has changed recently.

Contributing

Thank you for considering contributing to Validated DTO for Laravel! You can read the contribution guide here.

Security Vulnerabilities

Please review our security policy on how to report security vulnerabilities.

Credits

  • Wendell Adriel
  • All Contributors

License

Validated DTO for Laravel is open-sourced software licensed under the MIT license.

Issues· 0 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

PHPdata-transfer-objectdtolaravelvalidation

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类后端框架
定价开源

> 相关工具

N
Node.js
基于 V8 的 JavaScript 运行时
D
Django
Python 高级 Web 框架
S
Spring Boot
Java 生态主流微服务框架