PHPackages                             lumenated/fractal-views - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Templating &amp; Views](/categories/templating)
4. /
5. lumenated/fractal-views

ActiveLibrary[Templating &amp; Views](/categories/templating)

lumenated/fractal-views
=======================

A view abstraction for fractal

1.1.0(9y ago)114PHP

Since Mar 24Pushed 9y ago1 watchersCompare

[ Source](https://github.com/lumenated/fractal-views)[ Packagist](https://packagist.org/packages/lumenated/fractal-views)[ RSS](/packages/lumenated-fractal-views/feed)WikiDiscussions master Synced 4w ago

READMEChangelogDependencies (3)Versions (3)Used By (0)

Fractal views
=============

[](#fractal-views)

A view abstraction for Fractal making it more simple to integrate inside a framework.

[![fractal views](https://cloud.githubusercontent.com/assets/4613944/24282298/f421469c-105e-11e7-9c8d-404ec7d05ad2.png)](https://cloud.githubusercontent.com/assets/4613944/24282298/f421469c-105e-11e7-9c8d-404ec7d05ad2.png)[![Build Status](https://camo.githubusercontent.com/c726c23a447ca6a3763cad118183f9d359e3583dc0b58de9cb9acb88a2653c73/68747470733a2f2f7472617669732d63692e6f72672f6c756d656e617465642f6672616374616c2d76696577732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/lumenated/fractal-views)[![Coverage Status](https://camo.githubusercontent.com/f5cdc6df5fcbaa7b6a6885042e4411a8643733d0d617ac02b03b510430b4901d/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6c756d656e617465642f6672616374616c2d76696577732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/lumenated/fractal-views?branch=master)![Packagist](https://camo.githubusercontent.com/1a3da5bf9541c8e7433dc4b295a9f06a030d59dba49bdcee2bd6019a8986c8fb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6c756d656e617465642f6672616374616c2d76696577732e737667)![Packagist](https://camo.githubusercontent.com/9e1950f1f4609a1aadb82d1d26f08e34b2d0144ef23855e10937e1c0bb4fb32a/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c756d656e617465642f6672616374616c2d76696577732e737667)

Installation
============

[](#installation)

```
composer require lumenated/fractal-views
```

Configuration
=============

[](#configuration)

In order to use Fractal views for a resource we need to implement a transformer to map the resource to a serializable array and a view to present our resource to the consumer. A View extends the `Lumenated\FractalViews\Views` class which exposes two methods:

- renderOne which renders a single resource to an array
- renderMany which renders multiple objects to an array with pagination support

```
class BookView extends Lumenated\FractalViews\View
{
  // The fractal transformer that has to be used for this view
  protected $transformerClass = BookTransformer::class;
}
```

Next up we need to implement the `BookTransformer`. Below is an example from the [fractal documentation](http://fractal.thephpleague.com/transformers/):

```
