jooservices / dto
A PHP 8.5+ DTO and Data library with immutable DTOs and mutable Data objects
Requires
- php: >=8.5
Requires (Dev)
- captainhook/captainhook: ^5.23
- captainhook/plugin-composer: ^5.3
- fakerphp/faker: ^1.24
- friendsofphp/php-cs-fixer: ^3.65
- laravel/pint: ^1.18
- phpmd/phpmd: ^2.15
- phpstan/phpstan: ^2.0
- phpstan/phpstan-phpunit: ^2.0
- phpstan/phpstan-strict-rules: ^2.0
- phpunit/phpunit: ^12.0 || ^13.0
- squizlabs/php_codesniffer: ^3.8 || ^4.0
This package is auto-updated.
Last update: 2026-04-06 09:29:31 UTC
README
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
Install
composer require jooservices/dto
Quick example
use 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();
What is supported today
DtoandData- hydration from arrays, JSON strings, and simple public-property objects
- scalar, enum, and
DateTimeInterfacecasting - nested single DTO hydration
- opt-in validation with attributes
- serialization filtering and wrapping
- lazy derived serialization through
ComputesLazyProperties DataCollectionandPaginatedCollection
Important current limitations
- typed DTO arrays are not inferred from PHPDoc
- several declared attributes are not wired into the runtime yet, including
Pipeline,StrictType, andDiscriminatorMap Data::update()andData::set()do not re-run casting or validation
Documentation
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
AI Support
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.
Development
composer lint:all
composer test
Contributor workflow details live in:
GitHub Actions and Services
Current GitHub Actions coverage:
CI: security checks, linting, tests, coverage uploadRelease: 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. - The SonarCloud workflow step is currently commented out, so the old Sonar badge has been removed from this README.
License
This project is licensed under the MIT License.