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

AbandonedLibrary

paymaxi/fractal-bundle
======================

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

v1.0.4(8y ago)29.4kMITPHPPHP &gt;=7.1

Since May 30Pushed 4y ago1 watchersCompare

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

READMEChangelog (1)Dependencies (4)Versions (6)Used By (0)

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

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

[![Build Status](https://camo.githubusercontent.com/5062c2edcd0190d5d83a7095ad61d20722f8fe3566cc76b841ebdc75ef0e2369/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7061796d6178692f4672616374616c42756e646c652f6d61737465722e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/paymaxi/FractalBundle)[![Quality Score](https://camo.githubusercontent.com/0516eb043168e23413369dcffab99bcf7897b6b5061f9a04abc8b05ae800030f/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7061796d6178692f4672616374616c42756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/paymaxi/FractalBundle/)[![Coverage Status](https://camo.githubusercontent.com/20cd2e1f959c6b2500103955960a9da11e797bd23ef84ae53ee0644862aacd84/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7061796d6178692f4672616374616c42756e646c652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/paymaxi/FractalBundle//code-structure)[![Latest Version on Packagist](https://camo.githubusercontent.com/dc43dfc37c9968b256aa4a120613b9ca6a855cbce93068bb55faae9ece280334/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7061796d6178692f6672616374616c2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/paymaxi/fractal-bundle)[![Total Downloads](https://camo.githubusercontent.com/644b6b8433bd84ade81d7110936d5a96ed25cc1933a2fc48fc14531c6d89aedc/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7061796d6178692f6672616374616c2d62756e646c652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/paymaxi/fractal-bundle)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)

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 paymaxi/fractal-bundle

```

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

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

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.

License
-------

[](#license)

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

###  Health Score

32

—

LowBetter than 72% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity21

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity62

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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 ~66 days

Total

5

Last Release

3006d ago

PHP version history (2 changes)v1.0.0PHP &gt;=7.0

v1.0.4PHP &gt;=7.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/6d3834393f8093286a88277f704ad689eeb41333ed2d94ed12eb83e622901286?d=identicon)[dzubchik](/maintainers/dzubchik)

---

Top Contributors

[![dzubchik](https://avatars.githubusercontent.com/u/2685761?v=4)](https://github.com/dzubchik "dzubchik (13 commits)")[![samjarrett](https://avatars.githubusercontent.com/u/559397?v=4)](https://github.com/samjarrett "samjarrett (12 commits)")[![fesor](https://avatars.githubusercontent.com/u/172247?v=4)](https://github.com/fesor "fesor (8 commits)")[![michaelcullum](https://avatars.githubusercontent.com/u/211740?v=4)](https://github.com/michaelcullum "michaelcullum (2 commits)")

---

Tags

formatterfractalphpservicessymfonysymfony-bundle

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[scheb/2fa

Two-factor authentication for Symfony applications (please use scheb/2fa-bundle to install)

578630.7k1](/packages/scheb-2fa)[stfalcon/tinymce-bundle

This Bundle integrates TinyMCE WYSIWYG editor into a Symfony2 project.

2692.9M24](/packages/stfalcon-tinymce-bundle)[shopware/core

Shopware platform is the core for all Shopware ecommerce products.

595.2M386](/packages/shopware-core)[rikudou/psr6-dynamo-db-bundle

PSR-6 and PSR-16 cache implementation using AWS DynamoDB for Symfony

2077.8k](/packages/rikudou-psr6-dynamo-db-bundle)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)

PHPackages © 2026

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