PHPackages                             vakazona/dto - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Utility &amp; Helpers](/categories/utility)
4. /
5. vakazona/dto

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

vakazona/dto
============

A Data Transfer Object for PHP

v1.4(2y ago)11951MITPHPPHP ^8.0

Since Oct 9Pushed 2y ago1 watchersCompare

[ Source](https://github.com/VakaZona/DTO)[ Packagist](https://packagist.org/packages/vakazona/dto)[ RSS](/packages/vakazona-dto/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (5)Dependencies (2)Versions (6)Used By (1)

DTO
===

[](#dto)

Contents
--------

[](#contents)

- [Installation](#installation)
- [Usage](#usage)
- [Custom DTO](#custom-dto)
- [Tests](#tests)

Installation
------------

[](#installation)

```
composer require vakazona/dto

```

Usage
-----

[](#usage)

```
use vakazona\Dto\DTO;

class TestDTO extends DTO
{
    public string $name;

    public ?string $lastName;

    public string|int $age;

    public bool $developer = true;
}

$data = new TestDTO([
    'name' => 'Valery',
    'age' => 23,
]);

$data->name; // Valery
$data->age; // 23
$data->developer; // true
```

### Require

[](#require)

```
use vakazona\Dto\DTO;
use vakazona\Dto\Attributes\Required;

class TestDTO extends DTO
{
    #[Required]
    public string $price;
}

$data = new TestDTO([]);
```

> Exceptions\\InvalidDataException: The required property `price` is missing

### Flexible

[](#flexible)

```
use vakazona\Dto\DTO;
use vakazona\Dto\Attributes\Flexible;

#[Flexible]
class TestDTO extends DTO
{
    public string $name;
}

$data = new TesDTO([
    'name' => 'Valery',
    'age' => 23,
]);

$data->toArray(); // ['name' => 'Valery', 'age' => '23'];
```

Custom DTO
----------

[](#custom-dto)

### Custom property

[](#custom-property)

```
use vakazona\Dto\DTO;

class CustomPropertyDTO extends DTO
{
    public string $name;

    public int $age;

}
```

### Main property

[](#main-property)

```
use vakazona\Dto\DTO;

class TestCustomDTO extends DTO
{
    public CustomPropertyDTO $customProperty;
}
```

### Usage

[](#usage-1)

```
$data = new TestCustomDTO([
            'customProperty' => new CustomPropertyDTO([
                'name' => 'Valera',
                'age' => 23
            ])
        ]);
```

Tests
-----

[](#tests)

```
vendor/bin/phpunit

```

or

```
composer test

```

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity13

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~0 days

Total

5

Last Release

943d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/22f8f5002f21852236f224dc4bc45126115c81e4562b726edf59e548adeec054?d=identicon)[VakaZona](/maintainers/VakaZona)

---

Top Contributors

[![VakaZona](https://avatars.githubusercontent.com/u/108120394?v=4)](https://github.com/VakaZona "VakaZona (15 commits)")

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

![Health badge](/badges/vakazona-dto/health.svg)

```
[![Health](https://phpackages.com/badges/vakazona-dto/health.svg)](https://phpackages.com/packages/vakazona-dto)
```

###  Alternatives

[bizley/contenttools

ContentTools editor implementation for Yii 2.

8016.7k](/packages/bizley-contenttools)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
