PHPackages                             angrybytes/fractal - 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. [HTTP &amp; Networking](/categories/http)
4. /
5. angrybytes/fractal

ActiveLibrary[HTTP &amp; Networking](/categories/http)

angrybytes/fractal
==================

Handle the output of complex data structures ready for API output.

0.20.0(4y ago)0195MITPHPPHP &gt;=7.4

Since Jun 29Pushed 4y agoCompare

[ Source](https://github.com/AngryBytes/fractal)[ Packagist](https://packagist.org/packages/angrybytes/fractal)[ Docs](http://fractal.thephpleague.com/)[ RSS](/packages/angrybytes-fractal/feed)WikiDiscussions master Synced 1w ago

READMEChangelogDependencies (7)Versions (9)Used By (0)

Fractal
=======

[](#fractal)

[![Latest Version](https://camo.githubusercontent.com/49cc71f002ebbe18e2a5b5c812053bd03f9ac7c106995a249e873066e29e759a/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f72656c656173652f7468657068706c65616775652f6672616374616c2e7376673f7374796c653d666c61742d737175617265)](https://github.com/thephpleague/fractal/releases)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE)[![The PHP League Tests](https://github.com/thephpleague/fractal/workflows/The%20PHP%20League%20Tests/badge.svg)](https://github.com/thephpleague/fractal/workflows/The%20PHP%20League%20Tests/badge.svg)[![Coverage Status](https://camo.githubusercontent.com/3a194b83388485f7f4081de534c1d2b461dc3c3d639d2bd54bcb2027b8800225/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f636f7665726167652f672f7468657068706c65616775652f6672616374616c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/fractal/code-structure)[![Quality Score](https://camo.githubusercontent.com/61210fcd2cde96b241c359157d602312c306827196c53a2f688176289b47b5f4/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7468657068706c65616775652f6672616374616c2e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/thephpleague/fractal)[![Total Downloads](https://camo.githubusercontent.com/71d0dd491e5330f126fcc744938a6a989da6726bb3cc5a0ab591e0e167ccabcb/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6c65616775652f6672616374616c2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/league/fractal)

**NOTE: This is a fork that Angry Bytes maintains for compatiblity with newer versions of PHP.**

Fractal provides a presentation and transformation layer for complex data output, the like found in RESTful APIs, and works really well with JSON. Think of this as a view layer for your JSON/YAML/etc.

When building an API it is common for people to just grab stuff from the database and pass it to `json_encode()`. This might be passable for "trivial" APIs but if they are in use by the public, or used by mobile applications then this will quickly lead to inconsistent output.

Goals
-----

[](#goals)

- Create a protective shield between source data and output, so schema changes do not affect users
- Systematic type-casting of data, to avoid `foreach()`ing through and `(bool)`ing everything
- Include (a.k.a embedding, nesting or side-loading) relationships for complex data structures
- Work with standards like HAL and JSON-API but also allow custom serialization
- Support the pagination of data results, for small and large data sets alike
- Generally ease the subtle complexities of outputting data in a non-trivial API

This package is compliant with [PSR-1](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-1-basic-coding-standard.md), [PSR-2](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-2-coding-style-guide.md) and [PSR-4](https://github.com/php-fig/fig-standards/blob/master/accepted/PSR-4-autoloader.md). If you notice compliance oversights, please send a patch via pull request.

Install
-------

[](#install)

Via Composer

```
$ composer require league/fractal
```

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

[](#requirements)

The following versions of PHP are supported by this version.

- PHP 5.4
- PHP 5.5
- PHP 5.6
- PHP 7.0
- PHP 7.1
- PHP 7.2
- HHVM

Documentation
-------------

[](#documentation)

Fractal has [full documentation](http://fractal.thephpleague.com), powered by [Jekyll](http://jekyllrb.com/).

Contribute to this documentation in the [gh-pages branch](https://github.com/thephpleague/fractal/tree/gh-pages/).

Todo
----

[](#todo)

- add HAL serializers

Testing
-------

[](#testing)

```
$ phpunit
```

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](https://github.com/thephpleague/fractal/blob/master/CONTRIBUTING.md) and [CONDUCT](https://github.com/thephpleague/fractal/blob/master/CONDUCT.md) for details.

Maintainers
-----------

[](#maintainers)

- [Korvin Szanto](https://github.com/korvinszanto)
- [Matt Trask](https://github.com/matthewtrask)

Credits
-------

[](#credits)

- [Graham Daniels](https://github.com/greydnls)
- [Andrew Willis](https://github.com/willishq)
- [Phil Sturgeon](https://github.com/philsturgeon)
- [All Contributors](https://github.com/thephpleague/fractal/contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/thephpleague/fractal/blob/master/LICENSE) for more information.

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity10

Limited adoption so far

Community19

Small or concentrated contributor base

Maturity54

Maturing project, gaining track record

 Bus Factor5

5 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 ~904 days

Total

2

Last Release

1607d ago

PHP version history (2 changes)1.0.x-devPHP &gt;=7.2

0.20.0PHP &gt;=7.4

### Community

Maintainers

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

---

Top Contributors

[![philsturgeon](https://avatars.githubusercontent.com/u/67381?v=4)](https://github.com/philsturgeon "philsturgeon (49 commits)")[![willishq](https://avatars.githubusercontent.com/u/1564903?v=4)](https://github.com/willishq "willishq (34 commits)")[![greydnls](https://avatars.githubusercontent.com/u/1276798?v=4)](https://github.com/greydnls "greydnls (27 commits)")[![GrahamCampbell](https://avatars.githubusercontent.com/u/2829600?v=4)](https://github.com/GrahamCampbell "GrahamCampbell (20 commits)")[![localheinz](https://avatars.githubusercontent.com/u/605483?v=4)](https://github.com/localheinz "localheinz (15 commits)")[![livkiss](https://avatars.githubusercontent.com/u/256075?v=4)](https://github.com/livkiss "livkiss (14 commits)")[![duythien](https://avatars.githubusercontent.com/u/1762691?v=4)](https://github.com/duythien "duythien (11 commits)")[![matthewtrask](https://avatars.githubusercontent.com/u/4731244?v=4)](https://github.com/matthewtrask "matthewtrask (8 commits)")[![ipalaus](https://avatars.githubusercontent.com/u/248183?v=4)](https://github.com/ipalaus "ipalaus (8 commits)")[![KorvinSzanto](https://avatars.githubusercontent.com/u/1007419?v=4)](https://github.com/KorvinSzanto "KorvinSzanto (8 commits)")[![marcaddeo](https://avatars.githubusercontent.com/u/199649?v=4)](https://github.com/marcaddeo "marcaddeo (6 commits)")[![samsonasik](https://avatars.githubusercontent.com/u/459648?v=4)](https://github.com/samsonasik "samsonasik (6 commits)")[![vanbrabantf](https://avatars.githubusercontent.com/u/12281411?v=4)](https://github.com/vanbrabantf "vanbrabantf (6 commits)")[![webda2l](https://avatars.githubusercontent.com/u/517753?v=4)](https://github.com/webda2l "webda2l (5 commits)")[![niden](https://avatars.githubusercontent.com/u/1073784?v=4)](https://github.com/niden "niden (5 commits)")[![stephank](https://avatars.githubusercontent.com/u/89950?v=4)](https://github.com/stephank "stephank (5 commits)")[![bencorlett](https://avatars.githubusercontent.com/u/181919?v=4)](https://github.com/bencorlett "bencorlett (4 commits)")[![Elenthar](https://avatars.githubusercontent.com/u/10732888?v=4)](https://github.com/Elenthar "Elenthar (4 commits)")[![annuh](https://avatars.githubusercontent.com/u/2487949?v=4)](https://github.com/annuh "annuh (4 commits)")[![deefour](https://avatars.githubusercontent.com/u/14762?v=4)](https://github.com/deefour "deefour (4 commits)")

---

Tags

jsonapirestleague

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

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

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

###  Alternatives

[league/fractal

Handle the output of complex data structures ready for API output.

3.5k64.1M476](/packages/league-fractal)[serpapi/google-search-results-php

Get Google, Bing, Baidu, Ebay, Yahoo, Yandex, Home depot, Naver, Apple, Duckduckgo, Youtube search results via SerpApi.com

69114.3k](/packages/serpapi-google-search-results-php)[jsor/hal-client

A lightweight client for consuming and manipulating Hypertext Application Language (HAL) resources.

2425.9k1](/packages/jsor-hal-client)[elao/json-http-form-bundle

Adds support of JSON requests for Forms

356.0k](/packages/elao-json-http-form-bundle)

PHPackages © 2026

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