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

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

bluestone/dto
=============

Data transfer objects

v1.1.1(3y ago)21.2k2MITPHPPHP ^8.1

Since Nov 21Pushed 3y ago2 watchersCompare

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

READMEChangelogDependencies (4)Versions (13)Used By (2)

About DTO / Data transfer objects
=================================

[](#about-dto--data-transfer-objects)

[![Run tests](https://github.com/bluestonelab/dto/actions/workflows/run_tests.yml/badge.svg)](https://github.com/bluestonelab/dto/actions/workflows/run_tests.yml)[![Latest Stable Version](https://camo.githubusercontent.com/45394c67e5f7c1b9d4eb66b902e118476427ad58402158ad46c99c3674838c26/68747470733a2f2f706f7365722e707567782e6f72672f626c756573746f6e652f64746f2f762f737461626c65)](https://packagist.org/packages/bluestone/dto)

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

[](#installation)

This package requires `php:^8.1`.
You can install it via composer:

```
composer require bluestone/dto
```

Usage
-----

[](#usage)

This package goal to simplify the build of objects whose serve to pass structured data.

### Build simple DTO

[](#build-simple-dto)

An exemple of class extends DTO :

```
use Bluestone\DataTransferObject\DataTransferObject;

class Hooman extends DataTransferObject
{
    public string $name;
}
```

You can instantiate this class like this :

```
$jane = new Hooman(name: 'Jane');
$john = new Hooman(['name' => 'John']);
```

### Build complex DTO with Casting

[](#build-complex-dto-with-casting)

An exemple of class with property with casting :

```
use Bluestone\DataTransferObject\DataTransferObject;
use Bluestone\DataTransferObject\Attributes\CastWith;
use Bluestone\DataTransferObject\Casters\ArrayCaster;

class Hooman extends DataTransferObject
{
    public string $name;

    #[CastWith(ArrayCaster::class, type: Hooman::class)]
    public array $children;
}
```

You can instantiate this class like this :

```
$jane = new Hooman(
    name: 'Jane',
    children: [
        new Hooman(name: 'Mario'),
        new Hooman(name: 'Luigi'),
    ],
);

$john = new Hooman([
    'name' => 'John',
    'children' => [
        ['name' => 'Mario'],
        ['name' => 'Luigi'],
    ],
]);
```

### Build complex DTO with Mapping

[](#build-complex-dto-with-mapping)

An exemple of class with property with mapping :

```
use Bluestone\DataTransferObject\DataTransferObject;
use Bluestone\DataTransferObject\Attributes\Map;

class Hooman extends DataTransferObject
{
    #[Map('date_of_birth')]
    public string $bornAt;
}
```

You can instantiate this class like this :

```
$jane = new Hooman(
    date_of_birth: '1970-01-01',
);

$john = new Hooman([
    'date_of_birth' => '1970-01-01',
]);
```

Contributing
------------

[](#contributing)

DTO is an open source project under [MIT License](https://github.com/bluestonelab/dto/blob/master/LICENSE.md) and is [open for contributions](https://github.com/bluestonelab/dto/blob/master/CONTRIBUTING.md).

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community15

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor1

Top contributor holds 64% 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 ~1 days

Total

12

Last Release

1258d ago

Major Versions

v0.7.0 → v1.0.02022-12-06

### Community

Maintainers

![](https://www.gravatar.com/avatar/d65323c79234220d55e60e176f917e1c1db9b90215702e3e11f8b692977285b8?d=identicon)[Willi@m](/maintainers/Willi@m)

---

Top Contributors

[![william-suppo](https://avatars.githubusercontent.com/u/6459452?v=4)](https://github.com/william-suppo "william-suppo (16 commits)")[![actions-user](https://avatars.githubusercontent.com/u/65916846?v=4)](https://github.com/actions-user "actions-user (8 commits)")[![tof06](https://avatars.githubusercontent.com/u/2961054?v=4)](https://github.com/tof06 "tof06 (1 commits)")

---

Tags

entitydata-transfer-objectdto

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[cerbero/dto

Data Transfer Object (DTO)

17119.4k1](/packages/cerbero-dto)

PHPackages © 2026

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