lokus / dto
Package for creating DTOs
1.0.1
2025-08-10 20:09 UTC
Requires
- php: >=8.3
Requires (Dev)
- phpstan/phpstan: ^2.1
- phpunit/phpunit: ^12
- symfony/var-dumper: ^7.3
Suggests
None
Provides
None
Conflicts
None
Replaces
None
README
This package allows you to create DTO from array with providing validation of key names and parameteres of constructor, also validate types of array values.
Installation:
composer require lokus/dto
Example of usage:
use Lokus\Dto\SimpleDTO; final readonly class PostDTO extends SimpleDTO { public function __construct( public string $title, public string $content, ) {} } $data = [ 'title' => 'Simple Title', 'content' => 'Simple Content', ]; $dto = PostDTO::fromArray($data); echo $dto->title; echo $dto->content;