GithubHelp home page GithubHelp logo

ciarand / fractal Goto Github PK

View Code? Open in Web Editor NEW

This project forked from thephpleague/fractal

0.0 2.0 0.0 1.52 MB

Output complex, flexible, AJAX/RESTful data structures.

Home Page: fractal.thephpleague.com

License: MIT License

Ruby 0.61% PHP 99.39%

fractal's Introduction

This project is deprecated and unmaintained. Proceed with caution!

Fractal

Build Status Coverage Status Total Downloads Latest Stable Version

Fractal provides a presentation and transformation layer for complex data output, the like found in RESTful APIs, and works really well with JSON.

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" API's but if they are in use by the public, or used by an iPhone application then this will quickly lead to inconsistent output.

Goals

  • Create a "barrier" 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
  • Embed (or nest) relationships for complex data structures
  • 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, PSR-2 and PSR-4. If you notice compliance oversights, please send a patch via pull request.

Install

Via Composer

{
    "require": {
        "league/fractal": "0.7.*"
    }
}

Requirements

The following versions of PHP are supported by this version.

  • PHP 5.3
  • PHP 5.4
  • PHP 5.5
  • PHP 5.6

HHVM support is also experimentally supported. It basically works, but CodeSniffer installation is screwing it up on Travis-CI.

Documentation

Fractal has full documentation, powered by Sculpin.

Contribute to this documentation in the sculpin branch.

Todo

  • Switch return array to use instance properties in transform()
  • Implement HATEOAS/HAL links
  • Add smart embed syntax, e.g: ?embed=foo:limit(5):order(something,asc)

Testing

$ phpunit

Contributing

Please see CONTRIBUTING for details.

Credits

License

The MIT License (MIT). Please see License File for more information.

fractal's People

Contributors

ipalaus avatar marcaddeo avatar bencorlett avatar ceeram avatar art4 avatar daylerees avatar frankdejonge avatar martindilling avatar pborreli avatar helmut avatar ciarand avatar

Watchers

James Cloos avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.