rougin/datatables

PHP 对 Datatables 服务器端的封装。

dev-master / 1.0.x-dev 2020-10-06 01:26 UTC

This package is auto-updated.

Last update: 2024-09-06 10:06:33 UTC


README

Latest Version on Packagist Software License Build Status Coverage Status Quality Score Total Downloads

Datatables 是一个使用 Doctrine 或 Eloquent 来生成服务器端 AJAX 结果的包,几乎无需配置即可生成一个 Datatable 实例。DoctrineEloquent。请参阅 服务器端数据源示例Datatable 主页 以获取更多信息。

安装

通过 Composer 安装 Datatables

$ composer require rougin/datatables

基本用法

Doctrine

use Rougin\Datatables\DoctrineBuilder;

$entity = 'Acme\Doctrine\Models\User';

$builder = new DoctrineBuilder($manager, $entity, $_GET);

header('Content-Type: application/json');

echo json_encode($builder->make());

注意$manager 必须返回 Doctrine\ORM\EntityManager 的实例。请参阅 DoctrineBuilderTest::setUp 以获取示例实现。

Eloquent

use Rougin\Datatables\EloquentBuilder;

$model = 'Acme\Eloquent\Models\UserModel';

$builder = new EloquentBuilder($model, $_GET);

header('Content-Type: application/json');

echo json_encode($builder->make());

更新日志

请参阅 CHANGELOG 了解最近的变化。

测试

$ composer test

致谢

许可证

MIT 许可证 (MIT)。请参阅 LICENSE 了解更多信息。