承接 bastian/fractal-magic 相关项目开发

从需求分析到上线部署,全程专人跟进,保证项目质量与交付效率

邮箱:yvsm@zunyunkeji.com | QQ:316430983 | 微信:yvsm316

bastian/fractal-magic

Composer 安装命令:

composer require bastian/fractal-magic

包简介

A nice wrapper for the league's fractal package.

README 文档

README

Build Status

This package puts a nice wrapper around the fractal package: http://fractal.thephpleague.com. It handles the nitty gritty task of spinning up the manager, creating a resource and provides a convient location to register your transformers.

Installation

Add this to your composer.json require:

"bastian/fractal-magic": "dev-master"

and run composer update.

Usage

$fractal = new Hofmann\FractalMagic\Fractal([
  'posts' => new ResourceTransformer
]);

// Singular for a fractal item

$fractal->post(['title' => 'Hello']);

// Plural for a fractal collection

$fractal->posts([
  ['title' => 'Hi!']
]);

Notice that you only have to set the singular resource binding. This will return a Symfony response with the data in place, which you can return from your controller or route closure.

Laravel Usage

For usage in laravel I suggest you register a Response::macro like this:

Response::macro('fractal', function()
{
  return new Hofmann\FractalMagic\Fractal([
    'resource' => new ResourceTransformer
  ]);
});

Now you can use this in your controller:

class SomeController {

  public function index()
  {
    return Response::fractal()->resources($data);
  }
  
}

统计信息

  • 总下载量: 12
  • 月度下载量: 0
  • 日度下载量: 0
  • 收藏数: 4
  • 点击次数: 1
  • 依赖项目数: 0
  • 推荐数: 0

GitHub 信息

  • Stars: 3
  • Watchers: 1
  • Forks: 1
  • 开发语言: PHP

其他信息

  • 授权协议: Unknown
  • 更新时间: 2014-02-27

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固