PHPackages                             bastian/fractal-magic - 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. bastian/fractal-magic

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

bastian/fractal-magic
=====================

A nice wrapper for the league's fractal package.

0.2(12y ago)4121PHP

Since Feb 27Pushed 7y ago1 watchersCompare

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

READMEChangelog (2)Dependencies (4)Versions (5)Used By (0)

Fractal Wrapper
===============

[](#fractal-wrapper)

[![Build Status](https://camo.githubusercontent.com/85fa28e9acda01b70b81728c85c92c0922b72d9d597813aebb06b4d4bc72f114/68747470733a2f2f7472617669732d63692e6f72672f4261737469616e486f666d616e6e2f6672616374616c2d6d616769632e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/BastianHofmann/fractal-magic)

This package puts a nice wrapper around the fractal package: . It handles the nitty gritty task of spinning up the manager, creating a resource and provides a convient location to register your transformers.

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

[](#installation)

Add this to your `composer.json` require:

```
"bastian/fractal-magic": "dev-master"

```

and run `composer update`.

Usage
-----

[](#usage)

```
$fractal = new Hofmann\FractalMagic\Fractal([
  'posts' => new ResourceTransformer
]);

// Singular for a fractal item

$fractal->post(['title' => 'Hello']);

// Plural for a fractal collection

$fractal->posts([
  ['title' => 'Hi!']
]);
```

Notice that you only have to set the singular resource binding. This will return a Symfony response with the data in place, which you can return from your controller or route closure.

Laravel Usage
-------------

[](#laravel-usage)

For usage in laravel I suggest you register a `Response::macro` like this:

```
Response::macro('fractal', function()
{
  return new Hofmann\FractalMagic\Fractal([
    'resource' => new ResourceTransformer
  ]);
});
```

Now you can use this in your controller:

```
class SomeController {

  public function index()
  {
    return Response::fractal()->resources($data);
  }

}
```

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity56

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 91.7% of commits — single point of failure

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.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

4504d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4151945?v=4)[BastianHofmann](/maintainers/BastianHofmann)[@BastianHofmann](https://github.com/BastianHofmann)

---

Top Contributors

[![BastianHofmann](https://avatars.githubusercontent.com/u/4151945?v=4)](https://github.com/BastianHofmann "BastianHofmann (11 commits)")[![ericnkatz](https://avatars.githubusercontent.com/u/91019?v=4)](https://github.com/ericnkatz "ericnkatz (1 commits)")

### Embed Badge

![Health badge](/badges/bastian-fractal-magic/health.svg)

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

###  Alternatives

[illuminate/session

The Illuminate Session package.

9938.5M824](/packages/illuminate-session)[spatie/laravel-export

Create a static site bundle from a Laravel app

672139.5k6](/packages/spatie-laravel-export)[moonshine/moonshine

Laravel administration panel

1.3k239.9k76](/packages/moonshine-moonshine)[psalm/plugin-laravel

Psalm plugin for Laravel

3345.1M337](/packages/psalm-plugin-laravel)[illuminate/cookie

The Illuminate Cookie package.

224.5M132](/packages/illuminate-cookie)

PHPackages © 2026

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