PHPackages                             gergonzalez/lumen-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. [API Development](/categories/api)
4. /
5. gergonzalez/lumen-fractal

ActiveLaravel-package[API Development](/categories/api)

gergonzalez/lumen-fractal
=========================

League Fractal Wrapper

165PHP

Since Apr 7Pushed 8y ago2 watchersCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Lumen Fractal wrapper package
=============================

[](#lumen-fractal-wrapper-package)

This package provides an easy way to use [Fractal](http://fractal.thephpleague.com/) in Lumen.

[Fractal](http://fractal.thephpleague.com/) provides a presentation and transformation layer for complex data output, the like found in RESTful APIs.

Getting Started
---------------

[](#getting-started)

### Prerequisites

[](#prerequisites)

- Lumen &lt;= 5.4
- Lumen &gt; 5.4 - Not tested yet

Installation
------------

[](#installation)

Pull it via composer:

```
composer require gergonzalez/lumen-fractal
```

Once installed, register the service provider in your **bootstrap/app.php**

```
//Register Service Providers

$app->register(Gergonzalez\Fractal\FractalServiceProvider::class);
```

Usage
-----

[](#usage)

Implement your transformers, add a folder at **app/Http/Transformers** and put them there.

For example, **UserTransformer.php**:

```
namespace App\Http\Transformers;

use League\Fractal\TransformerAbstract;
use App\User;

class UserTransformer extends TransformerAbstract
{
    protected $availableIncludes = [
    ];

    protected $defaultIncludes = [
    ];

    /**
     * Turn User object into a generic array.
     *
     * @return array
     */
    public function transform(User $user)
    {
        return [
            'id' => $user->id,
            'email' => $user->email,
        ];
    }
}
```

And then, at your controller, if you retrieve only one item:

```
	use App\Http\Transformers\UserTransformer;

	class UserController extends Controller
	{

	    public function show(Request $request, $userId)
	    {
	        $user = User::findOrFail($userId);

	        return response()->json(app('fractal')->item($user, new UserTransformer())->getArray());
	    }

	}
```

Or a collection:

```
	use App\Http\Transformers\UserTransformer;

	class UserController extends Controller
	{

	    public function index(Request $request)
	    {
	        return response()->json(app('fractal')->collection(User::all(), new UserTransformer())->getArray());
	    }
	}
```

You can also use includes, defaults, etc. WIP docs.

If you need a real example of use, you can check [here](https://github.com/gergonzalez/funacademy-test)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENSE.md) for more information.

###  Health Score

21

—

LowBetter than 18% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community4

Small or concentrated contributor base

Maturity41

Maturing project, gaining track record

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/1520375?v=4)[Germán González Rodríguez](/maintainers/gergonzalez)[@gergonzalez](https://github.com/gergonzalez)

---

Tags

composerlumen

### Embed Badge

![Health badge](/badges/gergonzalez-lumen-fractal/health.svg)

```
[![Health](https://phpackages.com/badges/gergonzalez-lumen-fractal/health.svg)](https://phpackages.com/packages/gergonzalez-lumen-fractal)
```

###  Alternatives

[exsyst/swagger

A php library to manipulate Swagger specifications

35816.3M7](/packages/exsyst-swagger)[hubspot/api-client

Hubspot API client

24015.5M18](/packages/hubspot-api-client)[pocketmine/bedrock-protocol

An implementation of the Minecraft: Bedrock Edition protocol in PHP

172437.8k11](/packages/pocketmine-bedrock-protocol)[botman/driver-telegram

Telegram driver for BotMan

94452.6k6](/packages/botman-driver-telegram)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
