- Can I use this bundle directly in a Laravel project without Symfony conflicts?
- No, this is a Symfony bundle, not a Laravel package. You’ll need to either isolate it in a separate Composer project or create a wrapper script to avoid dependency conflicts with Laravel’s Symfony components (e.g., dependency-injection). Test thoroughly for Laravel-specific Doctrine features like traits or custom annotations.
- Will generated TypeScript models support Laravel’s soft deletes (deleted_at) or accessors?
- The bundle generates models based on Doctrine ORM metadata, so basic fields like `deleted_at` will appear. However, Laravel-specific features like accessors/mutators or observables may not translate automatically. Validate the output against your API contracts to ensure completeness.
- How do I handle Laravel’s Eloquent traits (e.g., HasFactory, ObservesEvents) in generated models?
- This bundle only processes Doctrine entities, not Eloquent traits. Traits like `HasFactory` or `ObservesEvents` won’t appear in the TypeScript output. Focus on generating models for Doctrine entities used in API responses, and manually document or exclude trait-related logic.
- Is there a way to integrate this with Laravel’s API Resources or Form Requests?
- Not natively. The bundle generates TypeScript models from Doctrine entities, but Laravel’s API Resources or Form Requests rely on Eloquent or custom logic. You’d need to post-process the generated models or write a custom script to merge them with API-specific validation rules.
- What’s the best way to run this in CI (e.g., GitHub Actions) for Laravel?
- Use the isolated approach: create a separate Symfony project with this bundle, generate models, and copy the output to your Laravel app’s `resources/js/types` or similar. Trigger this in CI as a pre-build step. Avoid running it directly in the Laravel project to prevent dependency conflicts.
- Are there alternatives with better Laravel support for Doctrine-to-TypeScript conversion?
- Yes. Consider custom scripts using `doctrine/annotations` to parse entities and generate TypeScript, or tools like `spatie/laravel-model-stubs` (for PHP stubs). For real-time sync, explore WebSocket-based solutions or tools like `graphql-codegen` if using GraphQL in Laravel.
- How do I configure the bundle to generate models for specific Doctrine namespaces?
- Use the `--className` flag to target individual entities (e.g., `php bin/console convert:entitytomodel --className=App\Entity\Order`). For namespaces, you’ll need to extend the bundle or pre-filter entities in a custom script, as the bundle lacks built-in namespace filtering.
- Will this work with Laravel 10’s Doctrine ORM (Symfony 6.4 backports)?
- Potentially, but test carefully. The bundle requires Symfony 6.2+, and Laravel 10’s Doctrine ORM includes backported Symfony components. Conflicts may arise with `symfony/dependency-injection` or other core dependencies. Run the generator in an isolated environment to mitigate risks.
- Can I customize the TypeScript output format (e.g., add interfaces or enums)?
- The bundle generates basic TypeScript models from Doctrine metadata. To customize formats (e.g., add interfaces or enums), you’ll need to extend the bundle’s templating logic or post-process the output with a script. Check the bundle’s `templates` directory for entry points.
- What’s the performance impact of running this in CI vs. local development?
- Performance depends on your entity count and CI environment. Running in CI adds overhead due to container startup, but the actual generation is lightweight. For large projects, cache Doctrine metadata or pre-generate models locally. Monitor CI runtime to optimize.