- Can I use this bundle directly in Laravel, or is it only for Symfony?
- This bundle is built for Symfony, but you can adapt it for Laravel by replacing Symfony components (e.g., TwigBundle with `spatie/laravel-twig-view` or Blade) and using Laravel’s routing, events, and Eloquent models. The core JSON generation logic remains reusable.
- How do I generate fixture documentation for Eloquent models instead of Doctrine entities?
- Replace Doctrine’s metadata scanning with a custom trait or annotation (e.g., `#[Fixture]` attribute) on Eloquent models. The bundle’s JSON generator can then process these models similarly, treating relationships and fields like Doctrine entities.
- Does this bundle support Laravel’s factories (e.g., `fakerphp/faker`) for dynamic fixtures?
- Yes, but you’ll need to extend the JSON generator to handle factory-generated data. Capture fixture data *after* seeding (e.g., via a `post-seed` event) and include it in the JSON output, just like manual or Doctrine fixtures.
- How do I configure the Twig/Blade template to display fixture data in Laravel?
- Use `spatie/laravel-twig-view` for Twig or adapt the template to Blade. The JSON output includes structured data (sections, tables, links), so you can render it with Blade’s `@foreach` loops and conditional logic for scalars/arrays/objects.
- Can I restrict access to the fixtures documentation page to authenticated users?
- Yes. In Laravel, wrap the route in middleware (e.g., `auth`) or use gate policies. The bundle’s Symfony `security.yml` equivalent can be replicated with Laravel’s `can()` checks or role-based middleware.
- What’s the best way to reload fixtures via an API endpoint in Laravel?
- Create a custom Artisan command (e.g., `php artisan fixtures:reload`) or an API route (e.g., `POST /api/fixtures/reset`) that triggers `Artisan::call('db:seed')`. Cache the JSON output to avoid regenerating it unless needed.
- Will this bundle work with large fixture datasets? How do I handle pagination?
- For large datasets, paginate the JSON output server-side (e.g., using `laravel-data-tables`) or client-side (JavaScript). The bundle’s Twig/Blade templates can integrate pagination controls like Laravel’s `paginate()` method.
- Are there alternatives to this bundle for Laravel that don’t require Symfony dependencies?
- Yes. Consider `laravel-fixtures` for seeding, `orchestra/testbench` for testing, or build a custom solution using Laravel’s `response()->json()` and Blade templates. Packages like `spatie/laravel-tags` can also help document relationships.
- How do I test the fixture documentation locally before deploying to production?
- Run `php artisan db:seed` to generate fixtures, then access the JSON endpoint (e.g., `/fixtures.json`) or Twig/Blade page. Use Laravel’s `cache:clear` to refresh the JSON if you modify fixtures or templates.
- Does this bundle support non-DB fixtures (e.g., API responses, uploaded files) in Laravel?
- Not natively, but you can extend the JSON generator to include custom data sources. For example, add a `fixtures:add` method to your service that accepts arrays or objects, then serialize them alongside Eloquent models in the output.