Download the PHP package andrewmclagan/laravel-fractal without Composer

On this page you can find all versions of the php package andrewmclagan/laravel-fractal. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package laravel-fractal

An easy to use Fractal wrapper built for Laravel applications

Latest Version on Packagist Build Status Quality Score StyleCI Total Downloads

The package provides a nice and easy wrapper around Fractal for use in your Laravel applications. If you don't know what Fractal does, take a peek at their intro. Shortly said, Fractal is very useful to transform data before using it in an API.

Using Fractal data can be transformed like this:

This package makes that process a tad easier:

Lovers of facades will be glad to know that a facade is provided:

There's also a very short syntax available to quickly transform data:

You can transform directly from a Laravel collection as well:

Transforming right from a Laravel collection is particularly useful for Eloquent results:

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Installation in Laravel 5.4

You can pull in the package via composer:

And then follow the installation instructions of the v4 branch of this package.

Installation in Laravel 5.5 and up

You can pull in the package via composer:

The package will automatically register itself.

If you want to change the default serializer, the default paginator, or the default fractal class Spatie\Fractal\Fractal you must publish the config file:

If you're upgrading to Laravel 5.5, the existing config file should be renamed from laravel-fractal.php to fractal.php

This is the contents of the published file:

Usage

Refer to the documentation of spatie/fractalistic to learn all the methods this package provides.

In all code examples you may use fractal() instead of Fractal::create().

Send a response with transformed data

To return a response with json data you can do this in a Laravel app.

The respond() method on the Fractal class can make this process a bit more streamlined.

You can pass a response code as the first parameter and optionally some headers as the second

You can pass json encoding options as the third parameter:

You can also set the status code and the headers using a callback:

Quickly creating a transformer

You can run the make:transformer command to quickly generate a dummy transformer. By default it will be stored in the app\Transformers directory.

Upgrading

From v4 to v5

Rename your config file from laravel-fractal to fractal

From v2 to v3

v3 was introduced to swap out the league/fractal with spatie/fractalistic. Support for Lumen was dropped. You should be able to upgrade a Laravel application from v2 to v3 without any code changes.

From v1 to v2

In most cases you can just upgrade to v2 with making none or only minor changes to your code:

The main reason why v2 of this package was tagged is because v0.14 of the underlying Fractal by the League contains breaking change. If you use the League\Fractal\Serializer\JsonApiSerializer in v2 the links key will contain self, first, next and last.

Changelog

Please see CHANGELOG for more information what has changed recently.

Testing

Contributing

Please see CONTRIBUTING for details.

Security

If you discover any security related issues, please email [email protected] instead of using the issue tracker.

Postcardware

You're free to use this package, but if it makes it to your production environment we highly appreciate you sending us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

We publish all received postcards on our company website.

Credits

Support us

Spatie is a webdesign agency based in Antwerp, Belgium. You'll find an overview of all our open source projects on our website.

Does your business depend on our contributions? Reach out and support us on Patreon. All pledges will be dedicated to allocating workforce on maintenance and new awesome stuff.

License

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


All versions of laravel-fractal with dependencies

PHP Build Version
Package Version
Requires php Version ^5.6|^7.0
illuminate/contracts Version ~5.1.0|~5.2.0|~5.3.0|~5.4.0
illuminate/support Version ~5.1.0|~5.2.0|~5.3.0|~5.4.0
spatie/fractalistic Version ^2.5
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package andrewmclagan/laravel-fractal contains the following files

Loading the files please wait ....