定制 vice/laravel-fractal 二次开发

按需修改功能、优化性能、对接业务系统,提供一站式技术支持

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

vice/laravel-fractal

Composer 安装命令:

composer require vice/laravel-fractal

包简介

Fractal helpers for Laravel 5

README 文档

README

Latest Version on Packagist Build Status Software License

Fractal lets you present API data in a consistent way, by acting as an anti-corruption layer between your frontend and backend.

Read up on Fractal here.

Installation

Require this package

composer require vice/laravel-fractal

And then add the following to the service providers in app.php

Vice\LaravelFractal\FractalServiceProvider::class,

Usage

To send a JSON representation of a single entity to the frontend simply

public function show($id)
{
    //...

    fractalResponse()->item($thing, new ThingTransformer);
}

To send a JSON representation of a collection of entities to the frontend simply

public function index()
{
    //...

    fractalResponse()->collection($things, new ThingTransformer);
}

The collection method also supports paginators, and will automatically append their state under a meta key

If you need to transform data without immediately using it in a response you may inject Vice\LaravelFractal\FractalService into your controller / class and use it as so:

$json = $this->fractalService->item($thing, new ThingTransformer)->toJson();

Contributing

Please open any issues or pull requests on GitHub. This package is maintained by max.brokman@vice.com

For PRs please run the style fixer (vendor/bin/php-cs-fixer fix) before submitting.

统计信息

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

GitHub 信息

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

其他信息

  • 授权协议: MIT
  • 更新时间: 2016-07-13

承接程序开发

PHP开发

VUE

Vue开发

前端开发

小程序开发

公众号开发

系统定制

数据库设计

云部署

网站建设

安全加固