markard/grid-data
最新稳定版本:0.1.5
Composer 安装命令:
composer require markard/grid-data
包简介
Grid data is package for generate json data for client grid js packages.
README 文档
README
It's the package for Laravel 4. The package prepares data for client side tables. Plus it handles all special input data from different client side libraries and provides common API.
Currently supported: Datatables
Quick start
Required setup
In the require key of composer.json file add the following
"markard/grid-data": "0.*"
Run the Composer update comand
$ composer update
In your config/app.php add 'Markard\GridData\GridDataServiceProvider' to the end of the providers array
'providers' => array(
'Illuminate\Foundation\Providers\ArtisanServiceProvider',
'Illuminate\Auth\AuthServiceProvider',
...
'Markard\GridData\GridDataServiceProvider',
),
At the end of config/app.php add 'GridData' => 'Markard\GridData\Facade' to the aliases array
'aliases' => array(
'App' => 'Illuminate\Support\Facades\App',
'Artisan' => 'Illuminate\Support\Facades\Artisan',
...
'GridData' => 'Markard\GridData\Facade',
),
Configuration
Run the artisan comand to publish config file
$ php artisan config:publish markard/grid-data
In your config/packages/markard/grid-data/grid-data.php set driver option.
Usage
1) Create a new file, for example UserGridRepository. Extend it from Markard\GridData\GridDataRepository.
<?php use Markard\GridData\GridDataRepository; class UserGridRepository extends GridDataRepository
You have to implement one required method:
public function getModel()
{
return new User();
}
2) In you controller:
public function index()
{
$gridData = GridData::init(new GridUserRepository(), Input::all());
return View::make('index')->withResponse($gridData->toArray());
}
API
GridDataRepository.phpgetModel()(Required) return Model model.hydrate(\Model $model)(Optional) return Eloquent Builder. This method executes aftergetModel().filter($query, array $filters)(Optional) return null. This method implements all filters to our model or builder if you overridedhydratemethod. There is already implemented some base functionality for filtering, if you need something more just override it.$filtersis an array of Markard\GridData\Filter instances.Markard\GridData\Filteris instance with two methods:getField()andgetValue().sort(array $sorts)(Optional) return null. This method implements all sorts to our model or builder if you overridedhydratemethod. There is already implemented some base functionality for sorting, if you need something more just override it.$sortsis an array of Markard\GridData\Sort instances.Markard\GridData\Sortis instance with two methods:getField()andgetOrder().dehydrate(Paginator $paginator)(Optional) return array. It is the last method before data will be generated. Is you need some special format of the returning data just override this method and return whatever you want.
Instance of this class will be returned after GridData::init was called.
filter(array $filters)set array ofMarkard\GridData\Filterwhich will be implemented to query.sort(array $sorts)set array ofMarkard\GridData\Sortwhich will be implemented to query.page($page)set current page.pageSize($pageSize)set page size.toArray()return array of data + metadata.toJson()return encoded result of the toArray method.
markard/grid-data 适用场景与选型建议
markard/grid-data 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 566 次下载、GitHub Stars 达 0, 最近一次更新时间为 2015 年 01 月 12 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「data」 「grid」 「laravel」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 markard/grid-data 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 markard/grid-data 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 markard/grid-data 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Shoot aims to make providing data to your templates more manageable
DataTables is a plug-in for the jQuery Javascript library. It is a highly flexible tool, based upon the foundations of progressive enhancement, which will add advanced interaction controls to any HTML table.
Plug-ins for DataTables
Adds the EDTF data type to Wikibase
A simple library that allows transform any kind of data to native php data or whatever
TYPO3 extension providing content elements powered by gridelements and bootstrap. Available elements: container, columns, tabs, accordion, tile unit and card.
统计信息
- 总下载量: 566
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 12
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2015-01-12