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

ActiveSymfony-bundle[API Development](/categories/api)

somnambulist/fractal-bundle
===========================

A port of samj/fractal-bundle for integrating TheLeague Fractal into Symfony

3.0.1(2w ago)334.3k↓47.8%11MITPHPPHP &gt;=8.3CI passing

Since Sep 30Pushed 2w ago3 watchersCompare

[ Source](https://github.com/somnambulist-tech/fractal-bundle)[ Packagist](https://packagist.org/packages/somnambulist/fractal-bundle)[ RSS](/packages/somnambulist-fractal-bundle/feed)WikiDiscussions main Synced 2d ago

READMEChangelogDependencies (14)Versions (10)Used By (1)

Somnambulist Fractal Bundle
===========================

[](#somnambulist-fractal-bundle)

[![GitHub Actions Build Status](https://camo.githubusercontent.com/df1c1787667aadfcc18d323ab3efcf16e71722b53c6792b42fde6d6d4d307bf3/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f616374696f6e732f776f726b666c6f772f7374617475732f736f6d6e616d62756c6973742d746563682f6672616374616c2d62756e646c652f74657374732e796d6c3f6c6f676f3d676974687562266272616e63683d6d61696e)](https://github.com/somnambulist-tech/fractal-bundle/actions?query=workflow%3Atests)[![Issues](https://camo.githubusercontent.com/e43d267a8146caa1c6a6e7bb2f24787cf4a4492fbcccd555e0405160290938e9/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6973737565732f736f6d6e616d62756c6973742d746563682f6672616374616c2d62756e646c653f6c6f676f3d676974687562)](https://github.com/somnambulist-tech/fractal-bundle/issues)[![License](https://camo.githubusercontent.com/7383cc5f4df3333c034b403faa8313ca535b32efb79516064c191878b6b9fdb7/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f736f6d6e616d62756c6973742d746563682f6672616374616c2d62756e646c653f6c6f676f3d676974687562)](https://github.com/somnambulist-tech/fractal-bundle/blob/main/LICENSE)[![PHP Version](https://camo.githubusercontent.com/8a742b12703e791915002c2bc02ecc559613c40fb3bbda64cb69c7a7aa7bd254/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f736f6d6e616d62756c6973742f6672616374616c2d62756e646c653f6c6f676f3d706870266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/somnambulist/fractal-bundle)[![Current Version](https://camo.githubusercontent.com/db8b318a14c4a1c83fa1d69ab1aff5c495737e324e451e56e90eea92c9576172/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f736f6d6e616d62756c6973742f6672616374616c2d62756e646c653f6c6f676f3d7061636b6167697374266c6f676f436f6c6f723d7768697465)](https://packagist.org/packages/somnambulist/fractal-bundle)

A fork and re-write of [samj/fractal-bundle](https://github.com/samjarrett/FractalBundle) to provide [Fractal](https://fractal.thephpleague.com)integration with the Symfony Framework.

Requirements
------------

[](#requirements)

- PHP 8.3+
- symfony/framework-bundle 7+

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

[](#installation)

Install using composer, or checkout / pull the files from github.com.

- composer require somnambulist/fractal-bundle

Usage
-----

[](#usage)

Add the `SomnambulistFractalBundle` to your `bundles.php` list if not registered by Symfony Flex.

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

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

This bundle allows auto-wiring / auto-configuring transformers as services. This allows you to take advantage of Symfonys container to resolve dependencies and reference transformers by class name (or service alias).

So long as the transformer extends from `League\Fractal\TransformerAbstract` or is tagged with `somnambulist.fractal_bundle.transformer`, it will be available to the Fractal Manager instance.

```
services:
    App\Http\Api\Transformers\:
        resource: '%kernel.project_dir%/Http/Api/Transformers/'
```

If transformers don't extend the `TransformerAbstract` be sure to tag them:

```
services:
    App\Http\Api\Transformers\:
        resource: '%kernel.project_dir%/Http/Api/Transformers/'
        tags: ['somnambulist.fractal_bundle.transformer']
```

**Note:** if your transformer is not registered as a service or passed as a valid callable or instance of `TransformerAbstract`, this library will raise an exception.

For example: to add an auth check to a `UserTransformer` (example from samj readme):

```
use League\Fractal\TransformerAbstract;

class UserTransformer extends TransformerAbstract
{
    public function __construct(private AuthorizationChecker $authorizationChecker)
    {
    }

    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;
    }
}
```

Reference the transformer by either a service alias name, or the class name:

```
$resource = new Collection($users, UserTransformer::class);
```

This works in includes as well:

```
public function includeFriends(User $user)
{
    return $this->collection($user->friends(), UserTransformer::class);
}
```

Look in the [sample application](tests/Fixtures) for some further examples.

Tests
-----

[](#tests)

PHPUnit 12+ is used for testing. Run tests via `vendor/bin/phpunit`.

###  Health Score

57

—

FairBetter than 98% of packages

Maintenance96

Actively maintained with recent releases

Popularity33

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity71

Established project with proven stability

 Bus Factor1

Top contributor holds 100% 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 ~214 days

Recently: every ~208 days

Total

9

Last Release

20d ago

Major Versions

1.1.0 → 2.0.02022-03-10

2.1.2 → 3.0.02026-06-13

PHP version history (3 changes)1.0.0PHP &gt;=8.0

2.1.0PHP &gt;=8.1

3.0.0PHP &gt;=8.3

### Community

Maintainers

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

---

Top Contributors

[![dave-redfern](https://avatars.githubusercontent.com/u/1477147?v=4)](https://github.com/dave-redfern "dave-redfern (14 commits)")

---

Tags

symfonyfractal

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[rcsofttech/audit-trail-bundle

Enterprise-grade, high-performance Symfony audit trail bundle. Automatically track Doctrine entity changes with split-phase architecture, multiple transports (HTTP, Queue, Doctrine), and sensitive data masking.

1189.8k](/packages/rcsofttech-audit-trail-bundle)[ahmed-bhs/doctrine-doctor

Runtime analysis tool for Doctrine ORM integrated into Symfony Web Profiler. Unlike static linters, it analyzes actual query execution at runtime to detect performance bottlenecks, security vulnerabilities, and best practice violations during development with real execution context and data.

9410.8k](/packages/ahmed-bhs-doctrine-doctor)[ecotone/symfony-bundle

Ecotone for Symfony — CQRS, Event Sourcing, Sagas, Durable Workflows, and Outbox on top of Symfony Messenger, via PHP attributes.

11249.0k1](/packages/ecotone-symfony-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1616.4k14](/packages/2lenet-crudit-bundle)[stfalcon-studio/api-bundle

Base classes and helper services to build API application via Symfony.

1035.6k](/packages/stfalcon-studio-api-bundle)

PHPackages © 2026

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