PHPackages                             jooservices/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. [Validation &amp; Sanitization](/categories/validation)
4. /
5. jooservices/dto

ActiveLibrary[Validation &amp; Sanitization](/categories/validation)

jooservices/dto
===============

A PHP 8.5+ DTO and Data library with immutable DTOs and mutable Data objects

v1.5.1(2w ago)03.2k↑2295%110MITPHPPHP &gt;=8.5CI passing

Since Jan 22Pushed 1w agoCompare

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

READMEChangelog (10)Dependencies (71)Versions (51)Used By (10)

JOOservices DTO Library
=======================

[](#jooservices-dto-library)

[![codecov](https://camo.githubusercontent.com/e9e53a1e34e5df42715c24f982095304304f0acd64a1cf32b50d64e9e301b6e2/68747470733a2f2f636f6465636f762e696f2f67682f6a6f6f73657276696365732f64746f2f6272616e63682f646576656c6f702f67726170682f62616467652e737667)](https://codecov.io/gh/jooservices/dto)[![CI](https://github.com/jooservices/dto/actions/workflows/ci.yml/badge.svg?branch=develop)](https://github.com/jooservices/dto/actions/workflows/ci.yml)[![Codacy Badge](https://camo.githubusercontent.com/75c315385ffa8750dcc89df32aa648243c099760e38a83c1a6c3093142b1f24d/68747470733a2f2f6170702e636f646163792e636f6d2f70726f6a6563742f62616467652f47726164652f6238306437613062363534653433653838616438323038363833336664343732)](https://app.codacy.com/gh/jooservices/dto/dashboard?utm_source=gh&utm_medium=referral&utm_content=&utm_campaign=Badge_grade)[![OpenSSF Scorecard](https://camo.githubusercontent.com/5d20c05727f505aec8aa1517dc2ea69ee38e5d7b35330a15c9eecbee56a6c1f0/68747470733a2f2f6170692e736563757269747973636f726563617264732e6465762f70726f6a656374732f6769746875622e636f6d2f6a6f6f73657276696365732f64746f2f6261646765)](https://securityscorecards.dev/viewer/?uri=github.com/jooservices/dto)[![PHP Version](https://camo.githubusercontent.com/2788132aa1e54031a6c94edcbf8688566d3e18cb5492cd1766836f74a24b27b5/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f5048502d382e352532422d626c75652e737667)](https://www.php.net/)[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](LICENSE)[![Packagist Version](https://camo.githubusercontent.com/ca29a71f84ecf058bc1a65f859aa2eea828c50d0b2e88601ef9a9dfac62209ec/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6a6f6f73657276696365732f64746f)](https://packagist.org/packages/jooservices/dto)

The **JOOservices DTO Library** is a PHP 8.5+ library for constructor-based DTO hydration, mutable data objects, opt-in validation, serialization control, and DTO collection wrappers.

Package name: `jooservices/dto`

Latest stable release: `v1.6.0`

Install
-------

[](#install)

```
composer require jooservices/dto
```

Quick example
-------------

[](#quick-example)

```
use JOOservices\Dto\Attributes\MapFrom;
use JOOservices\Dto\Core\Dto;

final class UserDto extends Dto
{
    public function __construct(
        public readonly string $id,
        #[MapFrom('email_address')]
        public readonly string $email,
        public readonly \DateTimeImmutable $createdAt,
    ) {}
}

$user = UserDto::from([
    'id' => 'u_123',
    'email_address' => 'john@example.com',
    'createdAt' => '2026-01-15T10:30:00+00:00',
]);

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

Design contract
---------------

[](#design-contract)

All DTOs are expected to declare a constructor with public promoted properties. While some helper methods may continue to work with constructor-less DTOs for backward compatibility, constructor-less DTOs are not part of the recommended or guaranteed API contract.

What is supported today
-----------------------

[](#what-is-supported-today)

- `Dto` and `Data`
- hydration from arrays, JSON strings, and simple public-property objects
- scalar, enum, and `DateTimeInterface` casting
- nested single DTO hydration
- class-level polymorphic DTO hydration with `#[DiscriminatorMap]`
- typed array hydration from common PHPDoc annotations such as `Type[]`, `array`, and `list`
- fallback property defaults with `#[DefaultFrom]`
- opt-in validation with attributes and standalone `Dto::validate()` on existing instances
- serialization filtering and wrapping
- lazy derived serialization through `ComputesLazyProperties`
- property-level `#[Pipeline]` and request-wide `Context::$globalPipeline`during hydration
- `DataCollection` and `PaginatedCollection`
- JSON Schema / OpenAPI generators with self-contained recursive `$ref`graphs
- `CastMode` validation plus optional decoupling of unknown-key rejection and scalar coercion

Important current limitations
-----------------------------

[](#important-current-limitations)

- deprecated placeholder attributes `Computed`, `Deprecated`, and `OptionalProperty` are not runtime-active (use `ComputesLazyProperties`, app-level deprecation, and nullable/defaults instead)
- `Context::$transformerMode` remains reserved and is not behavior-defining
- `CastWith` / `TransformWith` options are constructor-spread arguments for the configured class, not free-form bags passed into `cast()` / `transform()`

Documentation
-------------

[](#documentation)

Start with:

- [Documentation Hub](./docs/README.md)
- [Changelog](./CHANGELOG.md)
- [AI Skills Usage Guide](./ai/skills/USAGE.md)
- phpDocumentor config for future API reference generation: [`phpdoc.dist.xml`](./phpdoc.dist.xml)
- [Installation](./docs/01-getting-started/01-installation.md)
- [Quick Start](./docs/01-getting-started/02-quick-start.md)
- [Risks, Legacy, and Gaps](./docs/05-maintenance/01-risks-legacy-and-gaps.md)

AI Support
----------

[](#ai-support)

This repository includes an AI skill pack for agents working in Cursor, Claude Code, VS Code, JetBrains, and Antigravity.

Start with:

- [`AGENTS.md`](./AGENTS.md)
- [`CLAUDE.md`](./CLAUDE.md)
- [AI Skills Map](./ai/skills/README.md)
- [AI Skills Usage Guide](./ai/skills/USAGE.md)

The canonical skill source lives in [`.github/skills/`](./.github/skills/), with adapter layers for each supported AI environment.

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

[](#development)

```
composer lint
composer lint:all
composer test
composer test:coverage
composer check
composer ci
```

Contributor workflow details live in:

- [Setup](./docs/04-development/01-setup.md)
- [Contributing](./docs/04-development/07-contributing.md)
- [CI/CD](./docs/04-development/05-ci-cd.md)
- [Release Process](./docs/04-development/06-release-process.md)
- [AI Skills](./docs/04-development/08-ai-skills.md)

Approved Git flow summary:

- normal feature and fix work branches from `develop` and PRs back into `develop`
- release preparation uses `release/` from `develop`, then PRs into `master`
- releases are tagged from `master`
- `master` merges back into `develop` after release or hotfix completion

Community
---------

[](#community)

- [Contributing](./CONTRIBUTING.md)
- [Security Policy](./SECURITY.md)
- [Code of Conduct](./CODE_OF_CONDUCT.md)

GitHub Actions and Services
---------------------------

[](#github-actions-and-services)

Current GitHub Actions coverage:

- `CI`: security checks, lint matrix, tests, 98% minimum statement coverage, Codecov upload, Codacy coverage upload when `CODACY_API_TOKEN` is configured, and optional SonarQube Cloud analysis when `SONAR_TOKEN` is configured
- `Codacy`: uploads Codacy SARIF results to GitHub Code Scanning on pull requests, pushes to `master`, and a weekly schedule
- `Fortify`: required `Fortify AST` check on `master`/`develop`; skips cleanly when Fortify credentials are not configured
- `Release`: validate tags, create GitHub releases, trigger Packagist update
- `PR Labeler`: apply labels to pull requests
- `Semantic PR Title`: enforce pull request title format
- `OpenSSF Scorecard`: publish scorecard results as SARIF
- `Secret Scanning`: Gitleaks CLI via `.github/workflows/secret-scanning.yml` (shared `.gitleaks.toml`, no `GITLEAKS_LICENSE`)

External services currently used by workflows:

- `Codecov` for coverage upload in [`ci.yml`](./.github/workflows/ci.yml)
- `Codacy` for grade badge visibility and optional coverage upload via `CODACY_API_TOKEN` in [`ci.yml`](./.github/workflows/ci.yml)
- `Packagist` update webhook in [`release.yml`](./.github/workflows/release.yml)
- `GitHub Releases` and `GitHub Discussions` in [`release.yml`](./.github/workflows/release.yml)
- `OpenSSF Scorecard` in [`scorecard.yml`](./.github/workflows/scorecard.yml)
- `GitHub SARIF` upload through CodeQL infrastructure in [`scorecard.yml`](./.github/workflows/scorecard.yml)

Important notes:

- No workflow currently defines Docker-style `services:` containers such as MySQL, Redis, or PostgreSQL.
- SonarQube Cloud analysis is present in `ci.yml`, but it only runs after tests pass and only when `SONAR_TOKEN` is available.

License
-------

[](#license)

This project is licensed under the [MIT License](./LICENSE).

###  Health Score

55

—

FairBetter than 97% of packages

Maintenance98

Actively maintained with recent releases

Popularity24

Limited adoption so far

Community20

Small or concentrated contributor base

Maturity66

Established project with proven stability

 Bus Factor1

Top contributor holds 86% 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 ~16 days

Recently: every ~7 days

Total

13

Last Release

15d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/142772948?v=4)[JOOservices Ltd](/maintainers/jooservices)[@jooservices](https://github.com/jooservices)

---

Top Contributors

[![soulevilx](https://avatars.githubusercontent.com/u/2688707?v=4)](https://github.com/soulevilx "soulevilx (197 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (31 commits)")[![vietvu-sgcm](https://avatars.githubusercontent.com/u/236737387?v=4)](https://github.com/vietvu-sgcm "vietvu-sgcm (1 commits)")

---

Tags

castingcollectionscomposer-packagedata-objectdata-transfer-objectdtohydrationjooservicesmappingphpphp85serializationvalidationdatamappingdata-transfer-objectdtocastinghydrationnormalization

###  Code Quality

TestsPHPUnit

Static AnalysisPHPStan

Code StyleLaravel Pint

Type Coverage Yes

### Embed Badge

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

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

###  Alternatives

[wendelladriel/laravel-validated-dto

Data Transfer Objects with validation for Laravel applications

774680.8k19](/packages/wendelladriel-laravel-validated-dto)[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)[yorcreative/laravel-argonaut-dto

Argonaut is a lightweight Data Transfer Object (DTO) package for Laravel that supports nested casting, recursive serialization, and validation out of the box. Ideal for service layers, APIs, and clean architecture workflows.

1053.7k2](/packages/yorcreative-laravel-argonaut-dto)[fab2s/dt0

Immutable DTOs with bidirectional casting. No framework required. 8x faster than the alternative.

102.6k2](/packages/fab2s-dt0)[friendsofhyperf/validated-dto

The Data Transfer Objects with validation for Hyperf.

1515.6k](/packages/friendsofhyperf-validated-dto)

PHPackages © 2026

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