PHPackages                             nuxtifyts/php-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. nuxtifyts/php-dto

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

nuxtifyts/php-dto
=================

PHP DataTransferObject

v0.5.0(1y ago)01MITPHPPHP ~8.4CI passing

Since Dec 26Pushed 1y agoCompare

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

READMEChangelog (8)Dependencies (2)Versions (10)Used By (0)

PHP Pure Data objects
=====================

[](#php-pure-data-objects)

[![GitHub License](https://camo.githubusercontent.com/b934f2604290334dc904dbf180f97ec5ab8341a5c3a89d059b81d642171fb771/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e75787469667974732f7068702d64746f)](https://camo.githubusercontent.com/b934f2604290334dc904dbf180f97ec5ab8341a5c3a89d059b81d642171fb771/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f6e75787469667974732f7068702d64746f)[![Packagist Version](https://camo.githubusercontent.com/e4e532159627813160cfffdf5fa51ede6eb5189f8616f38578017db4556a32bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e75787469667974732f7068702d64746f)](https://camo.githubusercontent.com/e4e532159627813160cfffdf5fa51ede6eb5189f8616f38578017db4556a32bb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6e75787469667974732f7068702d64746f)[![PhpStan Level](https://camo.githubusercontent.com/d18b9a987aa81e64470a11caecf72caa66597c9ebd6b307bd1c2cb7a752b0dff/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e2e737667)](https://camo.githubusercontent.com/d18b9a987aa81e64470a11caecf72caa66597c9ebd6b307bd1c2cb7a752b0dff/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048505374616e2d6c6576656c25323031302d627269676874677265656e2e737667)[![PHPStan Checks](https://github.com/nuxtifyts/php-dto/actions/workflows/phpstan-tests.yml/badge.svg)](https://github.com/nuxtifyts/php-dto/actions/workflows/phpstan-tests.yml)[![CI Tests](https://github.com/nuxtifyts/php-dto/actions/workflows/php-tests.yml/badge.svg)](https://github.com/nuxtifyts/php-dto/actions/workflows/php-tests.yml)[![Test Coverage](https://raw.githubusercontent.com/nuxtifyts/php-dto/main/badge-coverage.svg)](https://packagist.org/packages/nuxtifyts/phpdto)

This package enabled the creation of data objects which can be used in various ways. Using modern PHP syntax, it allows you to hydrate data from arrays, objects, and other data sources. As well as carrying out the data, type validation and serialize the data for any purpose.

To create a `data` class, you will need to declare a `readonly` class that extends `Data` class. Then you can define the properties of the class and their types.

```
use Nuxtifyts\PhpDto\Data;
use Nuxtifyts\PhpDto\Attributes\Property\Aliases;
use Nuxtifyts\PhpDto\Attributes\Property\Computed;

final readonly class UserData extends Data
{
    #[Computed]
    public string $fullName;

    public function __construct(
        public string $firstName,
        #[Aliases('familyName')]
        public string $lastName
    ) {
        $this->fullName = "$this->firstName $this->lastName";
    }
}
```

You can then create an instance of the class from a mixed value. The DTO will then attempt to hydrate the object with the given data.

```
$data = [
    'firstName' => 'John',
    'lastName' => 'Doe',
];

$user = UserData::from($data);
```

DTOs can also be serialized to an array:

```
$user = new UserData('John', 'Doe');

$userData = $user->toArray();

// Or transform to a JSON string

$userData = $user->toJson();
```

Check out the [Quick start](https://github.com/nuxtifyts/php-dto/blob/main/docs/Quickstart.md) guide for more information.

### Note

[](#note)

This package was inspired from the [spatie/data-transfer-object](https://github.com/spatie/laravel-data) package. The main thing that I tried to focus on when creating this package is to make it outside of Laravel ecosystem, meaning: no dependency on [illuminate/support](https://github.com/illuminate/support).

### Requirements

[](#requirements)

- PHP 8.4 or higher
- That's it!

### Installation

[](#installation)

You can install the package via composer:

```
composer require nuxtifyts/php-dto
```

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance42

Moderate activity, may be stable

Popularity1

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity51

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 98.2% 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 ~5 days

Total

8

Last Release

471d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d23abe4e557ab602950aeaf2513d2622b72d8d5b080f851338038387caf33c9a?d=identicon)[Fa-BRAIK](/maintainers/Fa-BRAIK)

---

Top Contributors

[![Fa-BRAIK](https://avatars.githubusercontent.com/u/36890379?v=4)](https://github.com/Fa-BRAIK "Fa-BRAIK (164 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

data-deserializationdata-serializationdata-transfer-objectphp84

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[carlcs/craft-redactorcustomstyles

Redactor Custom Styles plugin for Craft CMS

59221.7k3](/packages/carlcs-craft-redactorcustomstyles)[apinstein/expiring-hash

A utililty to easily create crypographically signed URLs for temporary ad-hoc URL access.

1634.4k1](/packages/apinstein-expiring-hash)[serkanalgur/cmb2-field-faiconselect

Font Awesome icon selector for powerful custom metabox generator CMB2

202.2k](/packages/serkanalgur-cmb2-field-faiconselect)

PHPackages © 2026

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