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

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

zingle-com/dto
==============

Simple DTOs

1.0.0(6y ago)05.0kMITPHPPHP &gt;=7.2CI failing

Since Sep 19Pushed 6y ago3 watchersCompare

[ Source](https://github.com/Zingle/php-dto)[ Packagist](https://packagist.org/packages/zingle-com/dto)[ RSS](/packages/zingle-com-dto/feed)WikiDiscussions master Synced today

READMEChangelogDependencies (5)Versions (2)Used By (0)

Data Transfer Objects
=====================

[](#data-transfer-objects)

[![Build Status](https://camo.githubusercontent.com/7cdc4aa76183a73ee5c7d242133eed24398dbeb482961a1ab2a8f9c2ade679de/68747470733a2f2f7472617669732d63692e636f6d2f5a696e676c652f7068702d64746f2e7376673f6272616e63683d6d6173746572)](https://travis-ci.com/Zingle/php-dto)[![Coverage Status](https://camo.githubusercontent.com/75b52aed2c7e1d44cc38cea913ed81c5b4a24a56473f5fb445fdc29ccbc4cd4a/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f5a696e676c652f7068702d64746f2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/Zingle/php-dto?branch=master)

Simple library for creating and serializing DTO trees.

Why?
----

[](#why)

Serializing objects to arrays to transmit then as other types of data is a pain. This library makes it easy to create objects that decorate objects and describe their serialization behavior. Resolver will then walk the tree serializing as it goes, so you end up with a plain array. Pass it along to whatever you'd like to serialize the format to at that point.

Example
-------

[](#example)

```
use ZingleCom\DTO\Resolver;
use ZingleCom\DTO\Transmittable;
use Acme\SomeModel;

// Imagine that SomeModel has exposed getters on properties we'd like to serialize
class SomeModelDTO implements Transmittable
{
    /**
     * @var SomeModel
     */
    private $someModel;

    /**
     * @param SomeModel $someModel
     */
    public function __construct(SomeModel $someModel)
    {
        $this->someModel = $someModel;
    }

    public function toArray(): array
    {
        return [
            'id' => $this->someModel->getId(),
            'name' => $this->someModel->getName(),
            // imagine we have a related dto and model too
            'relatedModel' => new RelatedModelDTO('id' => $this->someModel->getRelatedModel()),
        ];
    }
}

// ... later you can do
// imagine $someModel is instantiated somewhere else
$resolver = new Resolver();
$data = $resolver->resolve(new SomeModelDTO($someModel));

// $data is now an array as described in DTOs, now we can serialize to whatever
$json = json_encode($data); // JSON for instance
```

Contribute
==========

[](#contribute)

Fork me and open a PR against master. We'll look at it.

###  Health Score

28

—

LowBetter than 51% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

Unknown

Total

1

Last Release

2522d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c07c0c54fce53a4e3d0f13300de39fcce4925cbe91cb4d6b294690a97e83b7c1?d=identicon)[zquintana](/maintainers/zquintana)

---

Top Contributors

[![zquintana](https://avatars.githubusercontent.com/u/130444?v=4)](https://github.com/zquintana "zquintana (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[drupol/phpartition

Partition problem for balanced arrays splitting made easy.

104.5k1](/packages/drupol-phpartition)

PHPackages © 2026

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