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

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);
});