dkx / slim-fractal-response
This package is abandoned and no longer maintained.
No replacement package was suggested.
Return item or collection from Fractal easily
0.0.1
2019-05-21 14:02 UTC
Requires
- php: ^7.3
- league/fractal: ^0.18.0
- nette/utils: >=2.5
- psr/http-message: ^1.0
- slim/slim: ^3.12
Requires (Dev)
- phpstan/extension-installer: ^1.0.1
- phpstan/phpstan: ^0.11.7
- phpstan/phpstan-strict-rules: ^0.11.1
This package is auto-updated.
Last update: 2024-01-22 01:32:40 UTC
README
Installation
$ composer require dkx/slim-fractal-response
Usage
Register middleware:
<?php
use DKX\SlimFractalResponse\FractalResponseMiddleware;
$app->add(new FractalResponseMiddleware($fractalManager));
Use in route:
<?php
use DKX\SlimFractalResponse\CollectionResponse;
use DKX\SlimFractalResponse\ItemResponse;
use Slim\Http\Request;
use Slim\Http\Response;
$app->get('/users', function (Request $request, Response $response): Response {
return new CollectionResponse($response, $userTransformer, $users);
});
$app->get('/users/{id}', function (Request $request, Response $response): Response {
return new ItemResponse($response, $userTransformer, $user);
});