- Can I use dualmedia/symfony-request-dto-bundle in vanilla Laravel (non-Lumen) projects?
- No, this bundle is designed for Symfony and Lumen. Vanilla Laravel lacks Symfony’s ArgumentResolver and Doctrine ORM, so integration would require custom middleware or a Symfony bridge (e.g., spatie/symfony-laravel-bridge), which adds significant complexity. For Eloquent-based Laravel, consider alternatives like spatie/laravel-data.
- What Laravel alternatives exist for automated DTO resolution and validation?
- For Laravel, consider spatie/laravel-data for DTOs, laravel-openapi for API docs, and laravel-validator for validation. These packages are natively compatible and avoid Symfony dependencies. If you need Doctrine ORM, explore doctrine/doctrine-bundle-laravel, but it’s not a drop-in replacement.
- How do I install this bundle in Lumen for DTO support?
- Install via Composer: `composer require dualmedia/symfony-request-dto-bundle`. Register the bundle in `config/app.php` under `config/bundles.php` (Symfony-style). Lumen’s built-in ArgumentResolver will automatically handle DTO resolution, similar to Symfony. No additional middleware is needed for basic functionality.
- Does this bundle work with Laravel’s Eloquent ORM, or only Doctrine?
- This bundle **requires Doctrine ORM** for entity loading (e.g., `#[FindOneBy]` attributes). Eloquent is not supported, so if your Laravel project relies on Eloquent, you’ll need to either switch to Doctrine or avoid this bundle. For Eloquent, manual DTO mapping or alternatives like spatie/laravel-data are better choices.
- Will this bundle conflict with Laravel’s built-in validation (e.g., Form Requests)?
- Yes, potential conflicts exist. Symfony’s Validator is stricter and may override Laravel’s validation rules. If using this bundle, avoid Laravel’s Form Requests or ensure validation rules align. Test thoroughly in a staging environment before production use.
- How does NelmioApiDoc integration work in Laravel? Is it compatible?
- NelmioApiDoc is **not compatible** with Laravel. This bundle’s API documentation features rely on Symfony’s Nelmio integration. For Laravel, use alternatives like darkaonline/l5-swagger or darkaonline/laravel-openapi. These packages generate OpenAPI/Swagger docs natively without Symfony dependencies.
- Can I use this bundle for performance-critical APIs? What’s the overhead?
- The bundle uses opcache-backed metadata caching to minimize reflection overhead after warm-up. For high-traffic APIs, this reduces runtime costs significantly. However, initial DTO resolution may introduce slight latency. Benchmark in your staging environment to assess impact, especially if using Doctrine ORM.
- How do I manually resolve DTOs in Laravel if I can’t use the bundle’s ArgumentResolver?
- Create middleware to parse requests into DTOs. For example, use Symfony’s `AbstractDto` as a base class and manually map request data (query, body, files) to DTO properties. Avoid reinventing the wheel—leverage libraries like symfony/property-access for safe property hydration. Example middleware is provided in the bundle’s docs.
- Is this bundle actively maintained? What’s the long-term viability for Laravel?
- The bundle is actively maintained (as of 2026), but Laravel-specific support is limited. If you’re using Lumen or a Symfony bridge, updates will align with Symfony’s roadmap. For vanilla Laravel, expect minimal updates unless a community fork emerges. Evaluate alternatives if long-term Laravel compatibility is critical.
- Does this bundle support nested DTOs, collections, or custom actions (e.g., `#[Action]`)?
- Yes, the bundle supports nested DTOs, collections, and custom actions via attributes like `#[Bag]`, `#[AsRoot]`, and `#[Action]`. These features are fully documented in the Symfony bundle’s README. In Lumen, they work out-of-the-box. In Laravel, you’d need to replicate this logic manually or via a Symfony bridge.