Thank you for considering contributing to the DTO library! This document provides guidelines and instructions for contributing.
-
Clone the repository:
git clone https://github.com/php-collective/dto.git cd dto -
Install dependencies:
composer install
-
Verify your setup:
composer check
- PHP 8.2 or higher
- Composer
This project follows PSR-12 with the PHPCollective ruleset. Before submitting code:
# Check for style violations
composer cs-check
# Auto-fix style issues
composer cs-fix# Run all tests
composer test
# Run specific test file
vendor/bin/phpunit tests/Generator/BuilderTest.php
# Run specific test method
vendor/bin/phpunit --filter testBuildWithEnumsThe project uses PHPStan at level 8:
composer stanRun all checks:
composer checkThis runs both code style checks and tests. Additionally run:
composer stan- Create a feature branch from
master - Make your changes
- Ensure all checks pass (
composer checkandcomposer stan) - Write or update tests for your changes
- Update documentation if needed (especially README.md and docs/)
- Submit a pull request to
master
When adding new features:
- Add tests - Create test cases in
tests/mirroring the source structure - Update documentation - Add or update docs in
docs/directory - Consider backwards compatibility - Avoid breaking changes when possible
Test fixtures for generated DTOs are in tests/Generator/Fixtures/. When adding tests that require new DTO classes or enums, add them there.
src/
├── Config/ # Configuration builder classes
├── Dto/ # Base DTO classes (runtime)
├── Engine/ # Config parsers and validators
├── Generator/ # Code generation logic
├── Importer/ # JSON Schema/data importers
└── Utility/ # Helper utilities
tests/
├── Config/ # Config builder tests
├── Dto/ # DTO runtime tests
├── Engine/ # Parser/validator tests
├── Generator/ # Generation tests
│ └── Fixtures/ # Test DTO classes
├── Importer/ # Importer tests
└── Utility/ # Utility tests
docs/ # VitePress documentation site
├── .vitepress/ # VitePress config and theme
├── guide/ # Tutorial and guide pages
├── reference/ # API/CLI reference pages
└── public/ # Static assets (logo, images)
The documentation site is built with VitePress and deployed to GitHub Pages.
cd docs
npm install # First time only
npm run docs:devThis starts a dev server at http://localhost:5173/dto/ with hot reload.
cd docs
npm run docs:builddocs/guide/- Tutorials, configuration, patterns (kebab-case filenames)docs/reference/- CLI, TypeScript, Importer referencedocs/.vitepress/config.ts- Navigation and sidebar configdocs/index.md- Homepage
- Add or edit markdown files in
docs/guide/ordocs/reference/ - Add frontmatter with title:
---\ntitle: Page Title\n--- - Update sidebar in
docs/.vitepress/config.tsif adding new pages - Preview locally with
npm run docs:dev
When reporting issues, please include:
- PHP version
- Library version
- Minimal code example to reproduce
- Expected vs actual behavior
- Error messages (if any)
Open an issue on GitHub for questions or discussions.