2017 © Pedro Peláez
 

cakephp-plugin cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

image

jeffersonsimaogoncalves/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  • Friday, June 8, 2018
  • by jeffersonsimaogoncalves
  • Repository
  • 1 Watchers
  • 0 Stars
  • 14 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 16 Versions
  • 0 % Grown

The README.md

CakePHP API Pagination

Latest Version on Packagist ![Software License][ico-license] Build Status ![Coverage Status][ico-scrutinizer] Quality Score ![Total Downloads][ico-downloads], (*1)

This is a simple component for CakePHP 3 which injects pagination information from CakePHP's Paginator into serialized JsonView and XmlView responses., (*2)

Install

Via Composer, (*3)

``` bash $ composer require bcrowe/cakephp-api-pagination, (*4)


Load the plugin in your application's `bootstrap.php` file: ``` php Plugin::load('BryanCrowe/ApiPagination');

Usage

Make sure your application has been set up to use data views; see the Enabling Data Views in Your Application section of the CakePHP documentation., (*5)

Then, load ApiPaginationComponent:, (*6)

``` php $this->loadComponent('BryanCrowe/ApiPagination.ApiPagination');, (*7)


Then, go ahead and set your paginated view variable like so: ``` php $this->set('articles', $this->paginate($this->Articles)); $this->set('_serialize', ['articles']);

Note: It is important that your _serialize variable is an array, e.g. ['articles'], so that your pagination information can be set under its own pagination key., (*8)

Your JsonView and XmlView responses will now contain the pagination information, and will look something like this:, (*9)

``` json { "articles": ["...", "...", "..."], "pagination": { "finder": "all", "page": 1, "current": 20, "count": 5000, "perPage": 20, "prevPage": false, "nextPage": true, "pageCount": 250, "sort": null, "direction": false, "limit": null, "sortDefault": false, "directionDefault": false } }, (*10)


### Configuring the Pagination Output ApiPagination has three keys for configuration: `key`, `aliases`, and `visible`. * `key` allows you to change the name of the pagination key. * `aliases` allows you to change names of the pagination detail keys. * `visible` allows you to set which pagination keys will be exposed in the response. **Note:** Whenever setting a key's visibility, make sure to use the aliased name if you've given it one. An example using all these configuration keys: ``` php $this->loadComponent('BryanCrowe/ApiPagination.ApiPagination', [ 'key' => 'paging', 'aliases' => [ 'page' => 'currentPage', 'current' => 'resultCount' ], 'visible' => [ 'currentPage', 'resultCount', 'prevPage', 'nextPage' ] ]);

This configuration would yield:, (*11)

``` json { "articles": ["...", "...", "..."], "paging": { "prevPage": false, "nextPage": true, "currentPage": 1, "resultCount": 20 } }, (*12)


## Changelog Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently. ## Testing ``` bash $ composer test

Contributing

Please see CONTRIBUTING and CONDUCT for details., (*13)

Security

If you discover any security related issues, please email bryan@bryan-crowe.com instead of using the issue tracker., (*14)

Credits

License

The MIT License (MIT). Please see License File for more information., (*15)

The Versions

08/06 2018

dev-master

9999999-dev https://github.com/jeffersonsimaogoncalves/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

api cakephp pagination cakephp3

08/06 2018

1.2.2

1.2.2.0 https://github.com/jeffersonsimaogoncalves/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

api cakephp pagination cakephp3

08/06 2018

1.2.1

1.2.1.0 https://github.com/jeffersonsimaogoncalves/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

api cakephp pagination cakephp3

31/05 2018

1.2.0

1.2.0.0 https://github.com/jeffersonsimaogoncalves/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

api cakephp pagination cakephp3

18/05 2016

1.1.0

1.1.0.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

10/03 2016

1.0.1

1.0.1.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

07/12 2015

1.0.0

1.0.0.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

23/11 2015

0.0.9

0.0.9.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

29/10 2015

0.0.8

0.0.8.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

19/10 2015

0.0.7

0.0.7.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

02/09 2015

0.0.6

0.0.6.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

28/08 2015

0.0.5

0.0.5.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

16/08 2015

0.0.4

0.0.4.0 https://github.com/bcrowe/cakephp-api-pagination

CakePHP 3 plugin that injects pagination information into API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination cakephp3

27/07 2015

0.0.3

0.0.3.0 https://github.com/bcrowe/cakephp-api-pagination

This packages provides a CakePHP component that adds pagination to your API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination

27/07 2015

0.0.2

0.0.2.0 https://github.com/bcrowe/cakephp-api-pagination

This packages provides a CakePHP component that adds pagination to your API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination

26/07 2015

0.0.1

0.0.1.0 https://github.com/bcrowe/cakephp-api-pagination

This packages provides a CakePHP component that adds pagination to your API responses.

  Sources   Download

MIT

The Requires

 

The Development Requires

api cakephp pagination