- Can I use this bundle directly in Laravel without Symfony?
- No, this bundle is Symfony-first. You’ll need to abstract Symfony components (like EventDispatcher or HttpFoundation) via Laravel’s Symfony Bridge or custom wrappers. Expect moderate effort for full integration, especially if using Doctrine.
- Does this support Laravel’s Eloquent ORM?
- No, it’s designed for Doctrine. To use Eloquent, you’d need a custom repository layer or a package like `spatie/laravel-doctrine-orm` to bridge the gap, which may require significant refactoring for complex queries.
- What Laravel versions does this bundle support?
- The bundle itself requires Symfony 7.1+, but Laravel compatibility depends on your abstraction layer. Test thoroughly with Laravel 10+ (PHP 8.2+) since Symfony’s DI and routing differ from Laravel’s ecosystem.
- How do I handle authentication in Laravel with this bundle?
- Symfony’s security component won’t integrate natively. Replace it with Laravel’s Auth, Gates, or Policies by wrapping the bundle’s middleware or using Laravel’s built-in auth middleware (e.g., `auth:api`).
- Are there performance concerns using Symfony’s event system in Laravel?
- Yes, Symfony’s event system adds overhead. Mitigate this by leveraging Laravel’s events/dispatchers instead of Symfony’s `EventSubscriber` where possible, or use a lightweight event bridge like `laravel-symfony-event-bridge`.
- Does this bundle support cursor pagination or DELETE 200 OK?
- No, these are optional JSON:API features not implemented. Cursor pagination requires custom logic (e.g., database cursors or offset limits), while DELETE 200 OK can be added with a simple middleware or controller override.
- How do I configure routes in Laravel to work with this bundle?
- Symfony’s YAML/XML routes won’t work directly. Use Laravel’s `Route::apiResource()` or create a custom macro like `Route::jsonApiResource()` to map to the bundle’s controllers. Example: `Route::jsonApiResource('articles', ArticleController::class).`
- What’s the best way to test this bundle in a Laravel project?
- Use Laravel’s testing tools (PestPHP or PHPUnit) but adapt Symfony’s test commands (e.g., `make:test`) to Laravel’s workflow. Focus on testing custom adapters (e.g., Eloquent repositories) and edge cases like sparse fieldsets or relationships.
- Are there alternatives for JSON:API in Laravel with less abstraction overhead?
- Yes, consider `laravel-json-api` (Eloquent-native) or `spatie/laravel-fractal` for lighter integration. These avoid Symfony dependencies but may offer less spec compliance or DX features like automatic eager loading.
- How do I handle sparse fieldsets (e.g., `fields[articles]=title`) in Laravel?
- The bundle handles this natively via Symfony’s serializer. For Eloquent, create a custom serializer or use a package like `spatie/laravel-query-builder` to filter fields before serialization.