Skip to content

2.0.0 — PHP 8.3-8.5 and Laravel 11-13 support

Latest

Choose a tag to compare

@maximebeaudoin maximebeaudoin released this 30 Sep 13:53

Version 2.0.0 modernizes the package for the current PHP and Laravel ecosystem. It requires PHP 8.3–8.5 and is tested against Laravel 11, 12 and 13. If you are on an older PHP or Laravel version, or on Lumen, stay on the 1.x branch.

Breaking changes

  • PHP requirement raised from >= 8.1 to ^8.3.
  • Lumen support removed (Lumen is no longer maintained): Laravel\LumenServiceProvider and the Laravel\Middleware\ParseInclude middleware are gone.
  • Testing\Laravel\AddTestingSupportForInclude trait removed. It patched Laravel 5.x testing internals and no longer worked. It is also no longer needed — see the fix for #42 below.
  • Contract changes in EllipseSynergie\ApiResponse\Contracts\Response — only relevant if you implement the interface directly (extending AbstractResponse requires no change):
    • Explicit nullable parameter types: ?string $resourceKey, ?Cursor $cursor (#59)
    • withError() and errorWrongArgs() now accept string|array $message, matching the behavior of errorWrongArgsValidator()
    • New methods declared: includes() and errorUnprocessable()
  • The Laravel response binding is now scoped and lazy. The Contracts\Response singleton is built on first resolution instead of at application boot. If you resolved it inside another service provider's boot() method to read parsed includes, be aware they now reflect the request at resolution time.

New

  • Fluent includes() method (#38): set the resources to embed directly on the response, without going through the Fractal manager:
    return $this->response->includes('author')->withItem($book, new BookTransformer);
    Accepts an array or a csv string.
  • errorUnprocessable() is now part of the Contracts\Response interface (it was implemented but missing from the contract).
  • league/fractal 0.21 is now allowed (^0.20.1 || ^0.21).

Fixed

  • No more deprecation notices on PHP 8.4+ for implicit nullable parameters (#59 — thanks @cboisen for pinpointing the fix).
  • The include query parameter now works in Laravel feature tests (#31, #42): because the response is built lazily, $this->json('GET', '/books', ['include' => 'author']) just works — no trait, no extra setup.
  • Laravel Octane compatibility: the scoped binding prevents the first request's includes from leaking into subsequent requests served by the same worker.
  • An absent or empty include parameter no longer registers an empty include on the Fractal manager.
  • The deprecated Response::api() macro now resolves the response from the container on each call instead of capturing a boot-time instance. Reminder: the macro remains deprecated — inject EllipseSynergie\ApiResponse\Contracts\Response instead.

Internal

  • CI now tests a PHP 8.3/8.4/8.5 × Laravel 11/12/13 matrix.
  • Tooling upgraded: PHPUnit 12, PHPStan 2, Psalm 6.
  • The Laravel service provider is now fully covered by tests (98%+ line coverage overall).

Upgrading from 1.x

  1. Ensure you run PHP >= 8.3 and Laravel >= 11, then composer require ellipsesynergie/api-response:^2.0.
  2. If you used the AddTestingSupportForInclude trait in your test suite, delete it — includes now work in tests natively.
  3. If you implement Contracts\Response directly, update your signatures (see breaking changes above).
  4. Lumen users: stay on ^1.0 (the 1.x branch).

Full changelog: 1.0.0...2.0.0