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
composer require jooservices/dtouse 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();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.
DtoandData- hydration from arrays, JSON strings, and simple public-property objects
- scalar, enum, and
DateTimeInterfacecasting - nested single DTO hydration
- class-level polymorphic DTO hydration with
#[DiscriminatorMap] - typed array hydration from common PHPDoc annotations such as
Type[],array<Type>, andlist<Type> - 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-wideContext::$globalPipelineduring hydration DataCollectionandPaginatedCollection- JSON Schema / OpenAPI generators with self-contained recursive
$refgraphs CastModevalidation plus optional decoupling of unknown-key rejection and scalar coercion
- deprecated placeholder attributes
Computed,Deprecated, andOptionalPropertyare not runtime-active (useComputesLazyProperties, app-level deprecation, and nullable/defaults instead) Context::$transformerModeremains reserved and is not behavior-definingCastWith/TransformWithoptions are constructor-spread arguments for the configured class, not free-form bags passed intocast()/transform()
Start with:
- Documentation Hub
- Changelog
- AI Skills Usage Guide
- phpDocumentor config for future API reference generation:
phpdoc.dist.xml - Installation
- Quick Start
- Risks, Legacy, and Gaps
This repository includes an AI skill pack for agents working in Cursor, Claude Code, VS Code, JetBrains, and Antigravity.
Start with:
The canonical skill source lives in .github/skills/, with adapter layers for each supported AI environment.
composer lint
composer lint:all
composer test
composer test:coverage
composer check
composer ciContributor workflow details live in:
Approved Git flow summary:
- normal feature and fix work branches from
developand PRs back intodevelop - release preparation uses
release/<version>fromdevelop, then PRs intomaster - releases are tagged from
master mastermerges back intodevelopafter release or hotfix completion
Current GitHub Actions coverage:
CI: security checks, lint matrix, tests, 98% minimum statement coverage, Codecov upload, Codacy coverage upload whenCODACY_API_TOKENis configured, and optional SonarQube Cloud analysis whenSONAR_TOKENis configuredCodacy: uploads Codacy SARIF results to GitHub Code Scanning on pull requests, pushes tomaster, and a weekly scheduleFortify: requiredFortify ASTcheck onmaster/develop; skips cleanly when Fortify credentials are not configuredRelease: validate tags, create GitHub releases, trigger Packagist updatePR Labeler: apply labels to pull requestsSemantic PR Title: enforce pull request title formatOpenSSF Scorecard: publish scorecard results as SARIFSecret Scanning: Gitleaks CLI via.github/workflows/secret-scanning.yml(shared.gitleaks.toml, noGITLEAKS_LICENSE)
External services currently used by workflows:
Codecovfor coverage upload inci.ymlCodacyfor grade badge visibility and optional coverage upload viaCODACY_API_TOKENinci.ymlPackagistupdate webhook inrelease.ymlGitHub ReleasesandGitHub Discussionsinrelease.ymlOpenSSF Scorecardinscorecard.ymlGitHub SARIFupload through CodeQL infrastructure inscorecard.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 whenSONAR_TOKENis available.
This project is licensed under the MIT License.