2017 © Pedro Peláez
 

yii2-extension rest-grid

For Yii2: This extension provides the ability like GridView but for REST.

image

vivre-tech/rest-grid

For Yii2: This extension provides the ability like GridView but for REST.

  • Monday, April 2, 2018
  • by microThread
  • Repository
  • 2 Watchers
  • 1 Stars
  • 21 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 50 % Grown

The README.md

This extension provides the ability like GridView but for REST., (*1)

For license information check the LICENSE-file., (*2)

Latest Stable Version Total Downloads Build Status, (*3)

Installation

The preferred way to install this extension is through composer., (*4)

Either run, (*5)

php composer.phar require --prefer-dist vivre-tech/rest-grid

or add, (*6)

"vivre-tech/rest-grid": "*"

to the require section of your composer.json., (*7)

Usage

Example:, (*8)

$arrayRows = [];
foreach(range(1, 100) as $item) {
    $arrayRows[] = [
        'id' => $item,
        'name' => 'Product ' . $item,
        'price' => 100 + $item,
        'created_at' => date('Y-m-d H:i:s')
    ];
}

$dataProvider = new \yii\data\ArrayDataProvider([
    'allModels' => $arrayRows,
    'pagination' => [
        'pageSize' => 5,
    ],
]);


$grid = new \vivretech\rest\grid\Grid([
    'dataProvider' => $dataProvider,
    'columns' => [
        [
            'attribute' => 'id'
        ],
        [
            'attribute' => 'name'
        ],
        [
            'attribute' => 'price'
        ],
        [
            'attribute' => 'created_at'
        ]
    ]
]);

return $grid->run();

Response

{
    "metadata": {
        "id": "aa899d9e6e420821e20f04ea857e0c2d_0",
        "caption": null,
        "description": null,
        "options": [],
        "header": {
            "show": true
        },
        "filters": {
            "show": true
        },
        "footer": {
            "show": false
        },
        "request_params": {
            "pager": {
                "param": "page",
                "size": "per-page"
            },
            "sorter": {
                "param": "sort",
                "separator": ",",
                "multi_sort": false
            }
        }
    },
    "pager": {
        "results": {
            "total": 1212,
            "per_page": 5
        },
        "pages": {
            "total": 243,
            "current": 1
        }
    },
    "columns": [
        {
            "label": "Id",
            "attribute": "id",
            "description": null,
            "options": [],
            "sortable": true,
            "filterable": false,
            "header": {
                "value": [],
                "options": []
            },
            "filter": {
                "selected": null,
                "items": [],
                "options": []
            },
            "footer": {
                "value": [],
                "options": []
            }
        },
        {
            "label": "Name",
            "attribute": "name",
            "description": null,
            "options": [],
            "sortable": true,
            "filterable": false,
            "header": {
                "value": [],
                "options": []
            },
            "filter": {
                "selected": null,
                "items": [],
                "options": []
            },
            "footer": {
                "value": [],
                "options": []
            }
        },
        {
            "label": "Price",
            "attribute": "price",
            "description": null,
            "options": [],
            "sortable": true,
            "filterable": false,
            "header": {
                "value": [],
                "options": []
            },
            "filter": {
                "selected": null,
                "items": [],
                "options": []
            },
            "footer": {
                "value": [],
                "options": []
            }
        },
        {
            "label": "Created At",
            "attribute": "created_at",
            "description": null,
            "options": [],
            "sortable": true,
            "filterable": false,
            "header": {
                "value": [],
                "options": []
            },
            "filter": {
                "selected": null,
                "items": [],
                "options": []
            },
            "footer": {
                "value": [],
                "options": []
            }
        }
    ],
    "items": [
        {
            "id": 1,
            "name": "Product 1",
            "price": 101,
            "created_at": "2018-04-02 17:54:52"
        },
        {
            "id": 2,
            "name": "Product 2",
            "price": 102,
            "created_at": "2018-04-02 17:54:52"
        },
        {
            "id": 3,
            "name": "Product 3",
            "price": 103,
            "created_at": "2018-04-02 17:54:52"
        },
        {
            "id": 4,
            "name": "Product 4",
            "price": 104,
            "created_at": "2018-04-02 17:54:52"
        },
        {
            "id": 5,
            "name": "Product 5",
            "price": 105,
            "created_at": "2018-04-02 17:54:52"
        }
    ]
}

Unit Testing

If you run the following command: composer install in a dev environment then you will find phpunit in /vendor/bin/phpunit., (*9)

In case phpunit in not installed via command composer install, just fallow next steps: 1. run in console/terminal brew install phpunit, (*10)

To test, in the root of the project, base on how phpunit is installed you will have two choices to run: 1. installed via command composer install you will have to execute in console/terminal: vendor/bin/phpunit 2. installed via brew you will have to execute in console/terminal: phpunit, (*11)

The Versions

02/04 2018

dev-master

9999999-dev

For Yii2: This extension provides the ability like GridView but for REST.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Banciu N. Cristian Mihai

api rest yii2 grid rest-grid

02/04 2018

1.0.3

1.0.3.0

For Yii2: This extension provides the ability like GridView but for REST.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Banciu N. Cristian Mihai

api rest yii2 grid rest-grid

10/01 2018

1.0.2

1.0.2.0

For Yii2: This extension provides the ability like GridView but for REST.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Banciu N. Cristian Mihai

api rest yii2 grid rest-grid

10/01 2018

1.0.1

1.0.1.0

For Yii2: This extension provides the ability like GridView but for REST.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Banciu N. Cristian Mihai

api rest yii2 grid rest-grid

05/01 2018

1.0.0

1.0.0.0

For Yii2: This extension provides the ability like GridView but for REST.

  Sources   Download

MIT

The Requires

 

The Development Requires

by Banciu N. Cristian Mihai

api rest yii2 grid rest-grid