PHPackages                             maxiviper117/dtokit-core - 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. maxiviper117/dtokit-core

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

maxiviper117/dtokit-core
========================

Framework-agnostic typed data boundaries for PHP

v0.1.0(1mo ago)00MITPHPPHP ^8.4CI passing

Since Jun 28Pushed 2w agoCompare

[ Source](https://github.com/Maxiviper117/DTOkit)[ Packagist](https://packagist.org/packages/maxiviper117/dtokit-core)[ Docs](https://github.com/Maxiviper117/DTOkit)[ RSS](/packages/maxiviper117-dtokit-core/feed)WikiDiscussions main Synced 2w ago

READMEChangelog (1)Dependencies (4)Versions (8)Used By (0)

DTOKit
======

[](#dtokit)

[![Tests](https://github.com/Maxiviper117/DTOkit/actions/workflows/tests.yml/badge.svg)](https://github.com/Maxiviper117/DTOkit/actions/workflows/tests.yml)[![PHPStan](https://github.com/Maxiviper117/DTOkit/actions/workflows/phpstan.yml/badge.svg)](https://github.com/Maxiviper117/DTOkit/actions/workflows/phpstan.yml)[![Latest Version](https://camo.githubusercontent.com/6aa1a873bbeda91fe83ca118d00e023fbef80062be081d92b4be54907d41b6ea/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d61786976697065723131372f64746f6b69742d636f72652e737667)](https://packagist.org/packages/maxiviper117/dtokit-core)[![PHP Version](https://camo.githubusercontent.com/6117912c1ec0b97f2c7187f16cee2efa885cb2f658bf885d015bb40d1dab9fb7/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d61786976697065723131372f64746f6b69742d636f72652e737667)](https://packagist.org/packages/maxiviper117/dtokit-core)[![License](https://camo.githubusercontent.com/1eae0170cb51ec47b8aa030a0d51db7002633ef38da0f70cf723facae2659c9b/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f4d61786976697065723131372f44544f6b69742e737667)](LICENSE.md)

DTOKit provides framework-agnostic typed data boundaries for PHP 8.4+. It maps arrays and objects into immutable data objects, serializes them safely, and explains mapping decisions and failures.

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

[](#installation)

```
composer require maxiviper117/dtokit-core
```

Basic usage
-----------

[](#basic-usage)

```
use DTOKit\InputData;

final readonly class CreatePostData extends InputData
{
    public function __construct(
        public string $title,
        public string $body,
        public ?int $categoryId = null,
    ) {}
}

$post = CreatePostData::from([
    'title' => 'Hello',
    'body' => 'World',
]);

$payload = $post->toArray();
```

`InputData` rejects unknown fields by default. `Data` and `OutputData` ignore them. Use `#[Strict]` or `#[IgnoreUnknown]` to override this per class.

Mapping and serialization
-------------------------

[](#mapping-and-serialization)

- Supported sources: associative arrays, `stdClass`, and public properties of plain objects.
- Supported values: typed scalars, nullable/defaulted fields, backed enums, `DateTimeInterface`, nested DTOKit objects, and lists declared with `#[ListOf]`.
- `#[MapInputName]` and `#[MapOutputName]` define external names.
- `#[WithCast]` and `#[WithTransformer]` invoke container-free extension classes.
- `#[Hidden]`, `#[Sensitive]`, and `#[Redact]` control safe output.
- Nullable accepts explicit `null`; only a constructor default makes a missing field optional.

```
use DTOKit\Attribute\ListOf;
use DTOKit\Attribute\MapInputName;

final readonly class OrderData extends InputData
{
    /** @param list $lines */
    public function __construct(
        #[MapInputName('order_id')] public int $orderId,
        #[ListOf(LineData::class)] public array $lines,
    ) {}
}
```

Non-throwing and explain APIs
-----------------------------

[](#non-throwing-and-explain-apis)

`Data::tryFrom()` returns a `MappingResult`. `Data::explain()` returns an `ExplainResult` with `toArray()`, `toJson()`, and `toText()` renderers. Diagnostics contain paths and types but never raw sensitive values.

Development
-----------

[](#development)

```
composer install
composer check
```

See [PRD.md](PRD.md) for product requirements, [Phases.md](Phases.md) for delivery status, and [AGENTS.md](AGENTS.md) for repository rules.

###  Health Score

39

—

LowBetter than 84% of packages

Maintenance94

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community9

Small or concentrated contributor base

Maturity46

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 61.1% 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

45d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/11472492?v=4)[David](/maintainers/Maxiviper117)[@Maxiviper117](https://github.com/Maxiviper117)

---

Top Contributors

[![Maxiviper117](https://avatars.githubusercontent.com/u/11472492?v=4)](https://github.com/Maxiviper117 "Maxiviper117 (11 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (4 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (3 commits)")

---

Tags

phpdataserializationmappingdto

###  Code Quality

TestsPest

Static AnalysisPHPStan, Rector

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

![Health badge](/badges/maxiviper117-dtokit-core/health.svg)

```
[![Health](https://phpackages.com/badges/maxiviper117-dtokit-core/health.svg)](https://phpackages.com/packages/maxiviper117-dtokit-core)
```

###  Alternatives

[hi-folks/data-block

Data class for managing nested arrays and JSON data.

1453.3k](/packages/hi-folks-data-block)[event4u/data-helpers

Framework-agnostic PHP library for data mapping, DTOs and utilities. Includes DataMapper, SimpleDto/LiteDto, DataAccessor/Mutator/Filter and helper classes (MathHelper, EnvHelper, etc.). Works with Laravel, Symfony/Doctrine or standalone PHP.

1434.6k](/packages/event4u-data-helpers)[iteks/laravel-enum

A comprehensive Laravel package providing enhanced enum functionalities, including attribute handling, select array conversions, and fluent facade interactions for robust enum management in Laravel applications.

2520.3k](/packages/iteks-laravel-enum)

PHPackages © 2026

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