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 today

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 43% 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

4454d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/8a4a9891d85127112b6bdab334623c6b588f39ce8a29ee14dde68b6216cd1a16?d=identicon)[BastianHofmann](/maintainers/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.

9937.4M753](/packages/illuminate-session)[illuminate/pipeline

The Illuminate Pipeline package.

9446.6M213](/packages/illuminate-pipeline)[illuminate/cookie

The Illuminate Cookie package.

224.3M122](/packages/illuminate-cookie)[interaction-design-foundation/laravel-geoip

Support for multiple Geographical Location services.

17221.0k3](/packages/interaction-design-foundation-laravel-geoip)[aedart/athenaeum

Athenaeum is a mono repository; a collection of various PHP packages

255.2k](/packages/aedart-athenaeum)

PHPackages © 2026

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