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

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

samj/fractal-bundle
===================

A Symfony Bundle for Fractal by League. Implements dependency injection into your transformers

4.0.0(5y ago)29318.1k↓23.2%11[4 issues](https://github.com/samjarrett/FractalBundle/issues)1MITPHPPHP &gt;=7.0

Since Sep 7Pushed 5y ago2 watchersCompare

[ Source](https://github.com/samjarrett/FractalBundle)[ Packagist](https://packagist.org/packages/samj/fractal-bundle)[ RSS](/packages/samj-fractal-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (5)Dependencies (3)Versions (11)Used By (1)

League Fractal Symfony Bundle
=============================

[](#league-fractal-symfony-bundle)

This bundle provides integration of [league/fractal](https://github.com/thephpleague/fractal) for Symfony. In addition it allows you to use [transformers as a services](#using-transformers-as-services).

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

[](#getting-started)

First of all you need to add dependency to composer.json:

```
composer require samj/fractal-bundle

```

Then register bundle in `app/AppKernel.php`:

```
public function registerBundles()
{
    return [
        // ...
        new SamJ\FractalBundle\SamJFractalBundle(),
    ];
}
```

Now we can write and use fractal transformers:

Using Transformers as Services
------------------------------

[](#using-transformers-as-services)

There are several cases when you need to pass some dependencies into transformer. The common one is [role/scope based results](https://github.com/thephpleague/fractal/issues/327) in transformers. For example you need to show `email` field only for administrators or owner of user profile:

```
class UserTransformer extends TransformerAbstract
{
    private $authorizationCheker;

    public function __construct(AuthorizationChecker $authorizationCheker)
    {
        $this->authorizationCheker = $authorizationCheker;
    }

    public function transform(User $user)
    {
        $data = [
            'id' => $user->id(),
            'name' => $user->name(),
        ];

        if ($this->authorizationChecker->isGranted(UserVoter::SEE_EMAIL, $user)) {
            $data['email'] = $user->email();
        }

        return $data;
    }
}
```

Then you could just register this class as service, and pass service ID as transformer. This bundle then will try to get it from container:

```
$resource = new Collection($users, 'app.transformer.user');
```

This works in includes as well:

```
public function includeFriends(User $user)
{
    return $this->collection($user->friends(), 'app.transformer.user');
}
```

You could see example of how to use transformers in [sample application](tests/Fixtures) which is used in test suites.

###  Health Score

40

—

FairBetter than 88% of packages

Maintenance17

Infrequent updates — may be unmaintained

Popularity45

Moderate usage in the ecosystem

Community20

Small or concentrated contributor base

Maturity64

Established project with proven stability

 Bus Factor1

Top contributor holds 56.8% 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 ~234 days

Recently: every ~244 days

Total

10

Last Release

2160d ago

Major Versions

0.3.0 → 1.0.02017-03-12

1.0.0 → 2.0.02017-10-14

2.1.0 → 3.0.02020-01-29

3.0.1 → 4.0.02020-06-19

PHP version history (4 changes)0.1.0PHP &gt;=5.3.3

0.2.0PHP &gt;=5.4

0.3.0PHP &gt;=5.6

3.0.0PHP &gt;=7.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/bbb377720371b71d65f8e8d9999127b5375cedbf18495b4e3dc55206cff0c604?d=identicon)[samjarrett](/maintainers/samjarrett)

---

Top Contributors

[![samjarrett](https://avatars.githubusercontent.com/u/559397?v=4)](https://github.com/samjarrett "samjarrett (21 commits)")[![fesor](https://avatars.githubusercontent.com/u/172247?v=4)](https://github.com/fesor "fesor (8 commits)")[![dave-redfern](https://avatars.githubusercontent.com/u/1477147?v=4)](https://github.com/dave-redfern "dave-redfern (4 commits)")[![michaelcullum](https://avatars.githubusercontent.com/u/211740?v=4)](https://github.com/michaelcullum "michaelcullum (2 commits)")[![beebeb](https://avatars.githubusercontent.com/u/100330779?v=4)](https://github.com/beebeb "beebeb (1 commits)")[![dependabot-preview[bot]](https://avatars.githubusercontent.com/in/2141?v=4)](https://github.com/dependabot-preview[bot] "dependabot-preview[bot] (1 commits)")

### Embed Badge

![Health badge](/badges/samj-fractal-bundle/health.svg)

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

###  Alternatives

[winzou/state-machine-bundle

Bundle for the very lightweight yet powerful PHP state machine

34010.4M15](/packages/winzou-state-machine-bundle)[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[sylius/taxonomy-bundle

Flexible categorization system for Symfony.

26388.2k7](/packages/sylius-taxonomy-bundle)[symfony/ai-bundle

Integration bundle for Symfony AI components

30282.3k6](/packages/symfony-ai-bundle)[sylius/addressing-bundle

Addressing and zone management for Symfony applications.

33221.4k3](/packages/sylius-addressing-bundle)[sylius/inventory-bundle

Flexible inventory management for Symfony applications.

19176.7k4](/packages/sylius-inventory-bundle)

PHPackages © 2026

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