Download the PHP package tamaspap/laravel5-fractal without Composer

On this page you can find all versions of the php package tamaspap/laravel5-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 laravel5-fractal

laravel5-fractal

A simple fractal service provider and transformer generator for laravel 5 and lumen

welcome to my first laravel package, lets rock.

New: Since version 1.2 auto class aliase has been removed.

Require this package with composer using the following command:

composer require cyvelnet/laravel5-fractal

Laravel 5

After updating composer, add the ServiceProvider to the providers array in config/app.php for laravel>=5

Cyvelnet\Laravel5Fractal\Laravel5FractalServiceProvider::class,

and register Facade

'Fractal' => Cyvelnet\Laravel5Fractal\Facades\Fractal::class

Lumen

register service provider in /bootstrap/app.php for lumen

$app->register(Cyvelnet\Laravel5Fractal\Laravel5FractalServiceProvider::class);

and uncomment the line

$app->withFacades();

and finally register Facade with

class_alias(Cyvelnet\Laravel5Fractal\Facades\Fractal::class, 'Fractal');

Now you can start using this package with the following simple command

$user = User::find(1);

return Fractal::item($user, new UserTransformer)->responseJson(200);

OR

$users = User::get(); // $users = User::paginate();

return Fractal::collection($users, new UserTransformer)->responseJson(200);

You will automatically gain some extra attributes when you passing a laravel's paginator object.

In case you would like to get only the transformed array, you may do

Fractal::collection($user, new UserTransformer)->getArray();

You may now generate transformer classes in artisan

php artisan make:transformer

in this case we are going to use artisan make:transformer UserTransformer, transformer file will automatically created in App\Transfomers\ directory

now you may open your generated transformer file and start formatting your data as you like

public function transform($user)
{
    return [
           'id' => $user->user_id,
           'name' => "{$user->user_firstname} {$user->user_lastname}",
           ...
           ];
}

You can also publish the config-file to change implementations to suits you.

php artisan vendor:publish

For the reason, number of changes to port to Lumen are very minimal, new branch will be added for future breaking changes between laravel 5 and lumen.

TO DO

All versions of laravel5-fractal with dependencies

PHP Build Version
Package Version
Requires php Version >=5.4.0
illuminate/support Version 5.0.x|5.1.x
tamaspap/fractal Version 0.13.*
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 tamaspap/laravel5-fractal contains the following files

Loading the files please wait ...