- What is php-collective/symfony-dto used for?
- It maps request data into typed data transfer objects so Symfony controllers can stay thin and focused on orchestration. The package provides attribute-driven request-to-DTO mapping, Symfony Validator integration, nested DTO support, and constructor promotion. It is aimed at explicit, testable input handling rather than passing raw arrays around.
- Can I use php-collective/symfony-dto in a Laravel application?
- Not natively. It is delivered as a Symfony bundle with Symfony config loading, so a Laravel app would need to run it alongside Symfony components or extract the framework-agnostic core. For most Laravel projects a native DTO package such as spatie/laravel-data is the cheaper option to own.
- How do I install php-collective/symfony-dto with Composer?
- It is installed as a Composer package under the name php-collective/symfony-dto. Because it is a Symfony bundle, installation also involves bundle registration and config discovery rather than a Laravel service provider. Treat the exact version constraint carefully and pin to 0.1.4 or ~0.1.4 while the package is pre-1.0.
- Does php-collective/symfony-dto support Laravel 10 or Laravel 11?
- There is no documented Laravel support. The package targets Symfony, and its bundle and config mechanics are not Laravel-native. Laravel 10 or 11 teams should validate the DTO need first and usually choose a Laravel-first package instead.
- How does request-to-DTO mapping work in php-collective/symfony-dto?
- Mapping is attribute-driven: request data is hydrated into DTO properties or constructor arguments instead of being left in arrays. The package supports nested DTOs and constructor promotion, and it integrates with Symfony Validator so constraints run against the mapped object. That keeps input handling explicit and unit-testable.
- Is php-collective/symfony-dto production-ready?
- It is pre-1.0 software, with 0.1.4 as the referenced release and no 1.0 stability guarantee. Minor 0.x releases may carry breaking changes, so pin the dependency exactly and avoid broad adoption before a time-boxed spike. Production use should be wrapped behind an internal interface so it can be swapped out.
- What changed in php-collective/symfony-dto 0.1.4?
- Version 0.1.4 aligns the PHP config format on dto.php consistently. That is a config filename convention change rather than a capability or public API change based on the release notes. Check any wrapper or fixture that hardcoded an older filename such as dto.config.php.
- Does php-collective/symfony-dto integrate with Symfony Validator and Serializer?
- Yes. The package advertises seamless Symfony Validator integration so DTO constraints can be validated after mapping, and it is described as compatible with Serializer. That makes it fit common Symfony request-handling workflows, though Laravel teams would still need to bridge those components themselves.
- How does php-collective/symfony-dto compare with spatie/laravel-data?
- spatie/laravel-data is built for Laravel and fits the framework's conventions directly, while php-collective/symfony-dto is a Symfony bundle with Symfony config and bundle mechanics. The DTO concepts overlap, but the delivery mechanism does not, so a Laravel codebase will usually pay less maintenance cost with the Laravel-native option. Choose symfony-dto only if you have a concrete reason to run Symfony components alongside Laravel.
- How should I test a php-collective/symfony-dto integration before adopting it?
- Run a time-boxed spike in a non-critical service and add an explicit smoke test for config discovery, especially that dto.php is resolved as expected. Unit-test DTO mapping and validation behaviour, including nested DTOs. If the spike succeeds, wrap the package behind an internal interface so domain code does not depend on it directly.