PHPackages                             rkulik/fractal - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. rkulik/fractal

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

rkulik/fractal
==============

Convenience wrapper for Fractal

1.0.0(7y ago)01MITPHPPHP ^7.2

Since Feb 10Pushed 7y ago1 watchersCompare

[ Source](https://github.com/rkulik/fractal)[ Packagist](https://packagist.org/packages/rkulik/fractal)[ Docs](https://github.com/rkulik/fractal)[ RSS](/packages/rkulik-fractal/feed)WikiDiscussions master Synced 2d ago

READMEChangelogDependencies (2)Versions (2)Used By (0)

fractal
=======

[](#fractal)

Convenience wrapper for [Fractal](https://fractal.thephpleague.com/).

- [Requirements](#requirements)
- [Install](#install)
- [Usage](#usage)
    - [Item examples](#item-examples)
        - [Callback for transformer](#callback-for-transformer)
        - [Class for transformer](#class-for-transformer)
    - [Collection example](#collection-example)
- [Testing](#testing)
- [Changelog](#changelog)
- [Contributing](#contributing)
- [Security](#security)
- [Credits](#credits)
- [License](#license)

Requirements
------------

[](#requirements)

This package requires PHP 7.2 or higher.

Install
-------

[](#install)

Via composer:

```
$ composer require rkulik/fractal
```

Usage
-----

[](#usage)

As this package wraps Fractal, the general usage is pretty much the same. The examples listed below demonstrate the basic workflow. For further information please refer to the [Fractal documentation](https://fractal.thephpleague.com/).

- [Item examples](#item-examples)
- [Collection example](#collection-example)

### Item examples

[](#item-examples)

In the following examples an item gets transformed and returned as an array. The transformation is done using either a [callback](#callback-for-transformer) or a [class](#class-for-transformer).

#### Callback for transformer

[](#callback-for-transformer)

```
