danilovl/doctrine-entity-dto-bundle
fetch="EAGER" or custom repository methods).doctrine/orm:^3.0).| Risk Area | Severity | Mitigation Strategy |
|---|---|---|
| Laravel-Symfony Gap | High | Abstract bundle via a facade or rewrite core logic in Laravel-compatible PHP. |
| Performance | Medium | Benchmark DTO generation vs. direct entity serialization; optimize with caching. |
| Maintenance Debt | Medium | Bundle is unmaintained (last release 2026, but no activity). Fork or patch if critical. |
| Testing | Low | Unit test DTO mappings; integration test API endpoints using DTOs. |
| Doctrine Version | High | Upgrade Laravel’s Doctrine to v3.x or use a compatibility layer. |
Why DTOs?
spatie/laravel-data, jenssegers/date) that could serve the same purpose with less friction?Laravel Compatibility
symfony/dependency-injection or symfony/http-kernel?DtoConverter) be simpler than integrating this bundle?Long-Term Viability
api-platform/core) with more community support?Entity Complexity
CI/CD Impact
null values)?DtoConverter facade that mimics the bundle’s functionality using reflection or annotations (e.g., #[AsDto]).// app/Services/DtoConverter.php
use Doctrine\ORM\EntityManagerInterface;
use ReflectionClass;
class DtoConverter {
public function __construct(private EntityManagerInterface $em) {}
public function toDto(object $entity, string $dtoClass): object {
$reflection = new ReflectionClass($dtoClass);
$dto = $reflection->newInstanceWithoutConstructor();
// Manual mapping logic...
return $dto;
}
}
symfony/http-kernel to bootstrap Symfony’s DI container alongside Laravel’s, then inject the bundle’s services where needed.spatie/laravel-data: Simpler, Laravel-native DTOs.jenssegers/date + Custom Logic: For lightweight needs.Assessment Phase (1–2 weeks)
Pilot Integration (2–3 weeks)
DtoConverter facade and test with 1–2 critical endpoints.Full Rollout (3–4 weeks)
Optimization (Ongoing)
Symfony\Component\Cache).symfony/validator).| Component | Compatibility Notes |
|---|---|
| Laravel 10.x | ✅ PHP 8.5+, Doctrine 3.x via doctrine/orm:^3.0. |
| Laravel 9.x | ❌ PHP 8.1–8.2; requires Doctrine 3.x upgrade or custom shim. |
| Doctrine ORM | ✅ v3.x required (Laravel’s default v2.x is incompatible). |
| Symfony Components | ⚠️ symfony/dependency-injection, symfony/config may conflict with Laravel’s DI. |
| API Platform | ❌ Incompatible (API Platform has its own DTO system). |
| GraphQL | ✅ Works well (DTOs can replace GraphQL resolvers for entities). |
Prerequisites
composer require doctrine/orm:^3.0
Bundle Integration (Symfony/Lumen)
composer require danilovl/doctrine-entity-dto-bundle
config/bundles.php.danilovl_doctrine_entity_dto.yaml.Laravel Facade Implementation
DtoConverter service (as above).AppServiceProvider:
public function register(): void {
$this->app->singleton(DtoConverter::class, function ($app) {
return new DtoConverter($app->make(EntityManagerInterface::class));
});
}
Entity Mapping
UserDto).API Layer Updates
// Before
return $userRepository->find($id);
// After
return $this->dtoConverter->toDto($userRepository->find($id), UserDto::class);
Testing
How can I help you explore Laravel packages today?