- How does paknahad/jsonapi-bundle compare to manually writing JSON:API endpoints in Laravel?
- This package leverages code generation via woohoolabs/yin to auto-create controllers, resources, and request handling, drastically reducing boilerplate. It enforces JSON:API compliance out-of-the-box (filtering, sorting, pagination, includes) while maintaining Laravel’s Eloquent integration. However, it trades runtime flexibility for speed—ideal for teams prioritizing consistency over customization.
- What Laravel versions does paknahad/jsonapi-bundle support?
- The package targets Laravel 8+ due to its reliance on Eloquent and modern PHP features. While no explicit version is listed, Yin (its dependency) typically aligns with Laravel’s latest LTS releases. Always check the package’s composer.json or GitHub issues for confirmed compatibility before adoption.
- Do I need to install woohoolabs/yin separately, and how does it work?
- Yes, woohoolabs/yin is a required dependency for code generation. You’ll install it globally via Composer (`composer global require woohoolabs/yin`) and run it as a CLI tool during development. Generated files (controllers, resources) are committed to version control—Yin isn’t a runtime dependency.
- Can I customize the JSON:API responses beyond the auto-generated structure?
- The package enforces JSON:API standards, so customizing responses (e.g., adding non-standard fields) may require extending generated classes or overriding templates. For complex needs, consider maintaining parallel manual API layers or using middleware to post-process responses.
- How does pagination work with paknahad/jsonapi-bundle?
- Pagination is built into the package and follows JSON:API’s `links` and `meta` specifications. It supports offset/limit by default and integrates with Laravel’s query builder. You can configure pagination defaults in the bundle’s service provider or override them per resource.
- Is paknahad/jsonapi-bundle suitable for production APIs with high traffic?
- The package is optimized for performance via code generation, but its suitability depends on your stack. Test under load, as Yin’s output may introduce debugging complexity. For critical paths, benchmark against alternatives like Fractal or Laravel’s native API Resources.
- What if my API requires non-JSON:API features like GraphQL or custom formats?
- paknahad/jsonapi-bundle is strictly for JSON:API compliance. For GraphQL, use Laravel Scout or Lighthouse. For custom formats, consider manual implementations or packages like Spatie’s API Resources, which offer more flexibility.
- How do I handle relationships (e.g., nested resources) with includes?
- The package supports JSON:API’s `include` parameter to fetch related resources in a single request. It auto-generates eager-loaded relationships based on Eloquent model definitions. For complex nested structures, ensure your models use proper `hasMany`, `belongsTo`, etc., relationships.
- Can I integrate paknahad/jsonapi-bundle with Laravel’s testing tools (e.g., Pest or PHPUnit)?
- Yes, but generated controllers may require custom assertions due to their auto-generated structure. Test API responses by hitting endpoints directly (e.g., `GET /api/posts?include=comments`) and verify JSON:API compliance using tools like `jsonapi-test` or manual checks for `data`, `links`, and `meta` fields.
- What’s the maintenance status of paknahad/jsonapi-bundle, and where can I get support?
- The package has limited public visibility (71 stars but no active repo), raising maintenance concerns. Check GitHub issues or contact the maintainer via the package’s composer.json metadata. For critical projects, consider alternatives like `spatie/laravel-fractal` or `darkaonline/l5-swagger` for better documentation and community support.