Repository navigation
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.1to^8.3. - Lumen support removed (Lumen is no longer maintained):
Laravel\LumenServiceProviderand theLaravel\Middleware\ParseIncludemiddleware are gone. Testing\Laravel\AddTestingSupportForIncludetrait 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 (extendingAbstractResponserequires no change):- Explicit nullable parameter types:
?string $resourceKey,?Cursor $cursor(#59) withError()anderrorWrongArgs()now acceptstring|array $message, matching the behavior oferrorWrongArgsValidator()- New methods declared:
includes()anderrorUnprocessable()
- Explicit nullable parameter types:
- The Laravel response binding is now scoped and lazy. The
Contracts\Responsesingleton is built on first resolution instead of at application boot. If you resolved it inside another service provider'sboot()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:Accepts an array or a csv string.return $this->response->includes('author')->withItem($book, new BookTransformer);
errorUnprocessable()is now part of theContracts\Responseinterface (it was implemented but missing from the contract).- league/fractal
0.21is 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
includequery 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
includeparameter 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 — injectEllipseSynergie\ApiResponse\Contracts\Responseinstead.
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
- Ensure you run PHP >= 8.3 and Laravel >= 11, then
composer require ellipsesynergie/api-response:^2.0. - If you used the
AddTestingSupportForIncludetrait in your test suite, delete it — includes now work in tests natively. - If you implement
Contracts\Responsedirectly, update your signatures (see breaking changes above). - Lumen users: stay on
^1.0(the1.xbranch).
Full changelog: 1.0.0...2.0.0