{"id":15560947,"url":"https://github.com/mixerapi/collection-view","last_synced_at":"2025-04-23T21:44:33.482Z","repository":{"id":56367662,"uuid":"296906369","full_name":"mixerapi/collection-view","owner":"mixerapi","description":"A CakePHP Collection View for displaying configurable pagination meta data in JSON or XML collection responses. [READ-ONLY]","archived":false,"fork":false,"pushed_at":"2024-03-25T23:50:23.000Z","size":66,"stargazers_count":1,"open_issues_count":0,"forks_count":1,"subscribers_count":2,"default_branch":"master","last_synced_at":"2024-04-26T11:22:30.610Z","etag":null,"topics":["cakephp","collections","json","pagination","serialization","xml"],"latest_commit_sha":null,"homepage":"https://mixerapi.com/plugins/collection-view","language":"PHP","has_issues":false,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"other","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/mixerapi.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE.txt","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":"2020-09-19T16:17:40.000Z","updated_at":"2024-02-17T22:20:44.000Z","dependencies_parsed_at":"2024-03-26T00:45:46.052Z","dependency_job_id":null,"html_url":"https://github.com/mixerapi/collection-view","commit_stats":{"total_commits":26,"total_committers":1,"mean_commits":26.0,"dds":0.0,"last_synced_commit":"97277f671550f89b9d616378c8f2cd00ad5a05dc"},"previous_names":[],"tags_count":30,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Fcollection-view","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Fcollection-view/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Fcollection-view/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/mixerapi%2Fcollection-view/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/mixerapi","download_url":"https://codeload.github.com/mixerapi/collection-view/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":250522292,"owners_count":21444509,"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":["cakephp","collections","json","pagination","serialization","xml"],"created_at":"2024-10-02T16:04:18.657Z","updated_at":"2025-04-23T21:44:33.463Z","avatar_url":"https://github.com/mixerapi.png","language":"PHP","funding_links":[],"categories":[],"sub_categories":[],"readme":"# MixerAPI CollectionView\n\n[![Latest Version on Packagist](https://img.shields.io/packagist/v/mixerapi/collection-view.svg?style=flat-square)](https://packagist.org/packages/mixerapi/collection-view)\n[![Build](https://github.com/mixerapi/mixerapi-dev/workflows/Build/badge.svg?branch=master)](https://github.com/mixerapi/mixerapi-dev/actions?query=workflow%3ABuild)\n[![Coverage Status](https://coveralls.io/repos/github/mixerapi/mixerapi-dev/badge.svg?branch=master)](https://coveralls.io/github/mixerapi/mixerapi-dev?branch=master)\n[![MixerApi](https://mixerapi.com/assets/img/mixer-api-red.svg)](https://mixerapi.com)\n[![CakePHP](https://img.shields.io/badge/cakephp-^4.2-red?logo=cakephp)](https://book.cakephp.org/4/en/index.html)\n[![Minimum PHP Version](https://img.shields.io/badge/php-^8.0-8892BF.svg?logo=php)](https://php.net/)\n\nA simple Collection View for displaying configurable pagination meta data in JSON or XML collection responses. Read\nmore at [MixerAPI.com](https://mixerapi.com).\n\n## Installation\n\n!!! info \"\"\n    You can skip this step if MixerAPI is installed. However, you will still new to define your viewClasses (read below).\n\n```console\ncomposer require mixerapi/collection-view\nbin/cake plugin load MixerApi/CollectionView\n```\n\nAlternatively after composer installing you can manually load the plugin in your Application:\n\n```php\n# src/Application.php\npublic function bootstrap(): void\n{\n    // other logic...\n    $this-\u003eaddPlugin('MixerApi/CollectionView');\n}\n```\n\n## Setup\n\nYour controllers must define their\n[view classes for content negotiation](https://book.cakephp.org/5/en/views/json-and-xml-views.html#defining-view-classes-to-negotiate-with).\n\n```php\nuse MixerApi\\CollectionView\\View\\JsonCollectionView;\nuse MixerApi\\CollectionView\\View\\XmlCollectionView;\n\npublic function viewClasses(): array\n{\n    return [JsonCollectionView::class, XmlCollectionView::class];\n}\n```\n\nThis can be done in your AppController to add them to all inheriting controllers or on a controller-by-controller basis.\n\n## Usage\n\nThat's it, you're done. Perform `application/xml` or `application/json` requests as normal. You may also request by\n`.xml` or `.json` extensions (assuming you've enabled them in your `config/routes.php`). This plugin will only modify\ncollections (e.g. controller::index action) requests, not item (e.g. controller::view action) requests.\n\n\u003cdetails\u003e\u003csummary\u003eJSON sample\u003c/summary\u003e\n  \u003cp\u003e\n\n```json\n{\n    \"collection\": {\n        \"url\": \"/films?page=3\u0026direction=desc\",\n        \"count\": 20,\n        \"total\": 1000,\n        \"pages\": 50,\n        \"next\": \"/films?page=4\",\n        \"prev\": \"/films?page=2\",\n        \"first\": \"/films\",\n        \"last\": \"/films?page=50\"\n    },\n    \"data\": [\n        {\n            \"id\": 1,\n            \"first_name\": \"PENELOPE\",\n            \"last_name\": \"GUINESS\",\n            \"modified\": \"2006-02-15T04:34:33+00:00\",\n            \"films\": [\n                {\n                    \"id\": 1,\n                    \"title\": \"ACADEMY DINOSAUR\",\n                    \"description\": \"A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies\",\n                    \"release_year\": \"2006\",\n                    \"language_id\": 1,\n                    \"rental_duration\": 6,\n                    \"length\": 86,\n                    \"rating\": \"PG\",\n                    \"special_features\": \"Deleted Scenes,Behind the Scenes\",\n                    \"modified\": \"2006-02-15T05:03:42+00:00\"\n                }\n            ]\n        }\n    ]\n}\n```\n\u003c/p\u003e\n\u003c/details\u003e\n\n\u003cdetails\u003e\u003csummary\u003eXML sample\u003c/summary\u003e\n  \u003cp\u003e\n\n```xml\n\u003cresponse\u003e\n  \u003ccollection\u003e\n    \u003curl\u003e/films?page=3\u0026amp;direction=desc\u003c/url\u003e\n    \u003ccount\u003e20\u003c/count\u003e\n    \u003ctotal\u003e1000\u003c/total\u003e\n    \u003cpages\u003e50\u003c/pages\u003e\n    \u003cnext\u003e/films?page=4\u003c/next\u003e\n    \u003cprev\u003e/films?page=2\u003c/prev\u003e\n    \u003cfirst\u003e/films\u003c/first\u003e\n    \u003clast\u003e/films?page=50\u003c/last\u003e\n  \u003c/collection\u003e\n  \u003cdata\u003e\n    \u003cid\u003e1\u003c/id\u003e\n    \u003cfirst_name\u003ePENELOPE\u003c/first_name\u003e\n    \u003clast_name\u003eGUINESS\u003c/last_name\u003e\n    \u003cmodified\u003e2/15/06, 4:34 AM\u003c/modified\u003e\n    \u003cfilms\u003e\n      \u003cid\u003e1\u003c/id\u003e\n      \u003ctitle\u003eACADEMY DINOSAUR\u003c/title\u003e\n      \u003cdescription\u003eA Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies\u003c/description\u003e\n      \u003crelease_year\u003e2006\u003c/release_year\u003e\n      \u003clanguage_id\u003e1\u003c/language_id\u003e\n      \u003crental_duration\u003e6\u003c/rental_duration\u003e\n      \u003clength\u003e86\u003c/length\u003e\n      \u003crating\u003ePG\u003c/rating\u003e\n      \u003cspecial_features\u003eDeleted Scenes,Behind the Scenes\u003c/special_features\u003e\n      \u003cmodified\u003e2/15/06, 5:03 AM\u003c/modified\u003e\n    \u003c/films\u003e\n  \u003c/data\u003e\n\u003c/response\u003e\n```\n\u003c/p\u003e\n\u003c/details\u003e\n\n## Configuration\n\nThis is optional. You can alter the names of the response keys, simply create a config/collection_view.php file. Using\nthe example below we can change the `collection` key to `pagination`, `data` to `items`, and alter some key names within\nour new pagination object. Just keep the mapped items `{{names}}` as-is.\n\n```php\n# config/collection_view.php\nreturn [\n    'CollectionView' =\u003e [\n        'pagination' =\u003e '{{collection}}', // array that holds pagination data\n        'pagination.url' =\u003e '{{url}}', // url of current page\n        'pagination.count' =\u003e '{{count}}', // items on the page\n        'pagination.total' =\u003e '{{total}}', // total database records\n        'pagination.pages' =\u003e '{{pages}}', // total pages\n        'pagination.next' =\u003e '{{next}}', // next page url\n        'pagination.prev' =\u003e '{{prev}}', // previous page url\n        'pagination.first' =\u003e '{{first}}', // first page url\n        'pagination.last' =\u003e '{{last}}', // last page url\n        'items' =\u003e '{{data}}', // the collection of data\n    ]\n];\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixerapi%2Fcollection-view","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmixerapi%2Fcollection-view","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmixerapi%2Fcollection-view/lists"}