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
composer require jooservices/dtouse DateTimeImmutable;
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();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
- serialization filtering and wrapping
- lazy derived serialization through
ComputesLazyProperties DataCollectionandPaginatedCollection
- several declared attributes are still only partially wired into runtime behavior;
Computed,Deprecated,OptionalProperty, andContext::$globalPipelineremain incomplete, andPipelinesupport is limited to current property-level execution paths rather than a broader end-to-end pipeline system StrictTypenow affects input shape enforcement and implicit casting rules, but related pipeline and schema behavior remains narrower than the declared attribute surface
Start with:
- Documentation Hub
- 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:
Current GitHub Actions coverage:
CI: security checks, linting, tests, 95% minimum statement coverage, coverage upload, and optional SonarQube Cloud analysis whenSONAR_TOKENis 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: workflow file exists, but thegitleaksjob is currently disabled
External services currently used by workflows:
Codecovfor coverage upload inci.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.