{"id":17984126,"url":"https://github.com/bcrowe/cakephp-api-pagination","last_synced_at":"2025-04-07T10:22:35.160Z","repository":{"id":35338381,"uuid":"39600560","full_name":"bcrowe/cakephp-api-pagination","owner":"bcrowe","description":":bookmark_tabs: CakePHP plugin that automatically adds fully configurable pagination metadata from CakePHP’s built-in pagination to JsonView or XmlView API responses by encapsulating payload data in an envelope.","archived":false,"fork":false,"pushed_at":"2024-01-13T16:17:17.000Z","size":67,"stargazers_count":40,"open_issues_count":1,"forks_count":14,"subscribers_count":4,"default_branch":"master","last_synced_at":"2025-03-31T07:09:33.105Z","etag":null,"topics":["api","cakephp","cakephp-api","cakephp-component","cakephp-json-view","cakephp-plugin","cakephp-view","cakephp-xml-view","component","envelope","metadata","pagination","paginator","php","rest-api"],"latest_commit_sha":null,"homepage":"","language":"PHP","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/bcrowe.png","metadata":{"files":{"readme":"README.md","changelog":"CHANGELOG.md","contributing":"CONTRIBUTING.md","funding":null,"license":"LICENSE.md","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-07-23T23:59:07.000Z","updated_at":"2024-10-29T11:22:25.000Z","dependencies_parsed_at":"2024-06-18T19:59:27.825Z","dependency_job_id":"bc992459-f4e7-43a3-a794-6c77b679ffb4","html_url":"https://github.com/bcrowe/cakephp-api-pagination","commit_stats":{"total_commits":98,"total_committers":8,"mean_commits":12.25,"dds":0.173469387755102,"last_synced_commit":"584c35af81f54e98986e18154800baf35e97060b"},"previous_names":[],"tags_count":18,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-api-pagination","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-api-pagination/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-api-pagination/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/bcrowe%2Fcakephp-api-pagination/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/bcrowe","download_url":"https://codeload.github.com/bcrowe/cakephp-api-pagination/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247632136,"owners_count":20970118,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["api","cakephp","cakephp-api","cakephp-component","cakephp-json-view","cakephp-plugin","cakephp-view","cakephp-xml-view","component","envelope","metadata","pagination","paginator","php","rest-api"],"created_at":"2024-10-29T18:19:33.314Z","updated_at":"2025-04-07T10:22:35.133Z","avatar_url":"https://github.com/bcrowe.png","language":"PHP","readme":"# CakePHP API Pagination\n\n[![Latest Version on Packagist][ico-version]][link-packagist]\n[![Software License][ico-license]](LICENSE.md)\n[![Build Status][ico-github]][link-github]\n[![Coverage Status][ico-scrutinizer]][link-scrutinizer]\n[![Quality Score][ico-code-quality]][link-code-quality]\n[![Total Downloads][ico-downloads]][link-downloads]\n\nThis is a simple component for CakePHP 4.2+ which injects pagination information\nfrom CakePHP's Paginator into serialized JsonView and XmlView responses.\n\nSee `1.x` and `2.x` releases and branches of this plugin for support of previous versions of CakePHP before `4.2`.\n\n## Install\n\nVia Composer\n\n``` bash\n$ composer require bcrowe/cakephp-api-pagination\n```\n\nLoad the plugin by adding `$this-\u003eaddPlugin('BryanCrowe/ApiPagination');` to the `bootsrap` method in your project’s `src/Application.php`:\n\n``` php\npublic function bootstrap(): void\n{\n    parent::bootstrap();\n    \n    // ... bootstrap code ...\n\n    // load more plugins here\n    \n    $this-\u003eaddPlugin('BryanCrowe/ApiPagination');\n}\n```\n\n## Usage\n\nMake sure your application has been set up to use data views; see the\n[Enabling Data Views in Your Application][link-dataviews] section of the CakePHP\ndocumentation.\n\nThen, load `ApiPaginationComponent`:\n\n``` php\n$this-\u003eloadComponent('BryanCrowe/ApiPagination.ApiPagination');\n```\n\nThen, go ahead and set your paginated view variable like so:\n\n``` php\n$this-\u003eset('articles', $this-\u003epaginate($this-\u003eArticles));\n$this-\u003eviewBuilder()-\u003esetOption('serialize', ['articles']);\n```\n**Note:** It is important that your `serialize` option is an array, e.g.\n`['articles']`, so that your pagination information can be set under its own\npagination key.\n\nYour JsonView and XmlView responses will now contain the pagination information,\nand will look something like this:\n\n``` json\n{\n    \"articles\": [\"...\", \"...\", \"...\"],\n    \"pagination\": {\n        \"finder\": \"all\",\n        \"page\": 1,\n        \"current\": 20,\n        \"count\": 5000,\n        \"perPage\": 20,\n        \"prevPage\": false,\n        \"nextPage\": true,\n        \"pageCount\": 250,\n        \"sort\": null,\n        \"direction\": false,\n        \"limit\": null,\n        \"sortDefault\": false,\n        \"directionDefault\": false\n    }\n}\n```\n\n### Configuring the Pagination Output\n\nApiPagination has four keys for configuration: `key`, `aliases`, `visible` and `model`.\n\n* `key` allows you to change the name of the pagination key.\n\n* `aliases` allows you to change names of the pagination detail keys.\n\n* `visible` allows you to set which pagination keys will be exposed in the\n  response. **Note:** Whenever setting a key's visibility, make sure to use the\n  aliased name if you've given it one.\n\n* `model` allows you to set the name of the model the pagination is applied on\n  if the controller does not follow CakePHP conventions, e.g. `ArticlesIndexController`.\n  Per default the model is the name of the controller, e.g. `Articles` for `ArticlesController`.\n\nAn example using all these configuration keys:\n\n``` php\n$this-\u003eloadComponent('BryanCrowe/ApiPagination.ApiPagination', [\n    'key' =\u003e 'paging',\n    'aliases' =\u003e [\n        'page' =\u003e 'currentPage',\n        'current' =\u003e 'resultCount'\n    ],\n    'visible' =\u003e [\n        'currentPage',\n        'resultCount',\n        'prevPage',\n        'nextPage'\n    ],\n    'model' =\u003e 'Articles',\n]);\n```\n\nThis configuration would yield:\n\n``` json\n{\n    \"articles\": [\"...\", \"...\", \"...\"],\n    \"paging\": {\n        \"prevPage\": false,\n        \"nextPage\": true,\n        \"currentPage\": 1,\n        \"resultCount\": 20\n    }\n}\n```\n\n## Changelog\n\nPlease see [CHANGELOG](CHANGELOG.md) for more information what has changed\nrecently.\n\n## Testing\n\n``` bash\n$ composer test\n```\n\n## Contributing\n\nPlease see [CONTRIBUTING](CONTRIBUTING.md) and [CONDUCT](CONDUCT.md) for\ndetails.\n\n## Security\n\nIf you discover any security related issues, please email bryan@bryan-crowe.com\ninstead of using the issue tracker.\n\n## Credits\n\n- [Bryan Crowe][link-author]\n- [All Contributors][link-contributors]\n\n## License\n\nThe MIT License (MIT). Please see [License File](LICENSE.md) for more\ninformation.\n\n[ico-version]: https://img.shields.io/packagist/v/bcrowe/cakephp-api-pagination.svg?style=flat-square\n[ico-license]: https://img.shields.io/badge/license-MIT-brightgreen.svg?style=flat-square\n[ico-github]: https://github.com/bcrowe/cakephp-api-pagination/workflows/CI/badge.svg\n[ico-scrutinizer]: https://img.shields.io/scrutinizer/coverage/g/bcrowe/cakephp-api-pagination.svg?style=flat-square\n[ico-code-quality]: https://img.shields.io/scrutinizer/g/bcrowe/cakephp-api-pagination.svg?style=flat-square\n[ico-downloads]: https://img.shields.io/packagist/dt/bcrowe/cakephp-api-pagination.svg?style=flat-square\n\n[link-packagist]: https://packagist.org/packages/bcrowe/cakephp-api-pagination\n[link-github]: https://github.com/bcrowe/cakephp-api-pagination/actions\n[link-scrutinizer]: https://scrutinizer-ci.com/g/bcrowe/cakephp-api-pagination/code-structure\n[link-code-quality]: https://scrutinizer-ci.com/g/bcrowe/cakephp-api-pagination\n[link-downloads]: https://packagist.org/packages/bcrowe/cakephp-api-pagination\n[link-author]: https://github.com/bcrowe\n[link-contributors]: ../../contributors\n[link-dataviews]: https://book.cakephp.org/4/en/views/json-and-xml-views.html#enabling-data-views-in-your-application\n","funding_links":[],"categories":["REST and API"],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcrowe%2Fcakephp-api-pagination","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbcrowe%2Fcakephp-api-pagination","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbcrowe%2Fcakephp-api-pagination/lists"}