- Can I use ACSEOFastShowGeneratorBundle in Laravel instead of Symfony?
- The bundle is designed for Symfony 5/6 and relies on Doctrine ORM and Symfony’s annotation/YAML stack. For Laravel, you’d need a Doctrine bridge (like `laravel-doctrine/orm`) or build an Eloquent adapter to translate YAML/annotations into Laravel’s conventions. Blade templating would also require custom directives or JSON responses.
- How do I configure field labels and visibility in Laravel?
- For Laravel, YAML configuration is more practical than annotations. Store YAML files in `config/fastshowgenerator/` (e.g., `MyEntity.default.fastshowgenerator.yml`) and define `label`, `show`, and `groups` per property. Use the bundle’s YAML driver to fetch showable data, then adapt it for Blade or API responses.
- Does this bundle support Eloquent relationships in Laravel?
- No, the bundle is built for Doctrine entities and doesn’t natively handle Eloquent relationships. You’d need to manually map relationships in YAML or build a custom adapter to integrate with Eloquent’s accessors or API resources.
- What’s the performance impact of generating showable data dynamically?
- The bundle caches Doctrine metadata (via Symfony’s `MetadataFactory`), but Laravel’s cache drivers may not align perfectly. For high-traffic APIs, pre-generate showable data in a service or cache the YAML configuration separately to avoid runtime reflection overhead.
- How do I render the generated data in Laravel Blade instead of Twig?
- The bundle outputs a structured array for Twig. In Laravel, convert this to Blade-compatible data (e.g., an array of `[label => value]` pairs) and loop through it in your view. Alternatively, create a Blade directive to render fields dynamically, like `@showFields($data)`.
- Is there a simpler alternative for Laravel without Symfony dependencies?
- For Laravel, consider lightweight alternatives like custom Eloquent accessors, `spatie/laravel-query-builder` for dynamic fields, or API resources (e.g., `laravel/api-resources`). These avoid Symfony’s dependency bloat and align with Laravel’s conventions. The bundle’s value is in its metadata-driven approach, but it’s overkill for simple projects.
- How do I handle multiple groups (e.g., ‘admin’ vs. ‘public’) in Laravel?
- Use the `groups` option in YAML to define group-specific fields (e.g., `groups: {default, admin}`). In your controller, call `setGroup('admin')` before fetching `getShowableData()`. For Laravel, filter the resulting array in your service layer to exclude non-public fields from Blade/API responses.
- Will this bundle work with Laravel’s API resources (e.g., `laravel/api-resources`)?
- Indirectly, yes. Use the bundle’s YAML driver to define field visibility/groups, then pass the generated data to an API resource’s `toArray()` method. This combines the bundle’s metadata logic with Laravel’s API resource serialization. Avoid annotations if using Eloquent.
- What PHP/Symfony/Laravel versions does this bundle support?
- The bundle requires **PHP 7.4+**, **Symfony 5/6**, and Doctrine ORM. For Laravel, you’ll need **Laravel 8+** (for PHP 8.0+) and a Doctrine bridge (e.g., `laravel-doctrine/orm`). Check compatibility with your Laravel version’s Doctrine integration, as older bridges may lack Symfony 6 support.
- How do I test this bundle in a Laravel project?
- Mock the Doctrine `ClassMetadata` interface to test the bundle’s core logic. For Laravel-specific tests, verify YAML parsing and data transformation into Blade/JSON. Use PHPUnit’s `createMock()` to simulate the Symfony container’s service injection. Focus on edge cases like missing properties or invalid groups.