PHPackages                             mixerapi/collection-view - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. mixerapi/collection-view

ActiveCakephp-plugin[Parsing &amp; Serialization](/categories/parsing)

mixerapi/collection-view
========================

A simple Collection View for displaying pagination meta data in JSON or XML collection responses

v2.0.7(3mo ago)173.3k↑35.4%11MITPHPPHP ^8.1

Since Sep 27Pushed 2mo ago1 watchersCompare

[ Source](https://github.com/mixerapi/collection-view)[ Packagist](https://packagist.org/packages/mixerapi/collection-view)[ RSS](/packages/mixerapi-collection-view/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (8)Versions (34)Used By (1)

MixerAPI CollectionView
=======================

[](#mixerapi-collectionview)

[![Latest Version on Packagist](https://camo.githubusercontent.com/2b7d632a57a785b25326e03e7631134107bf2d59dbf79bb134c0ba289ead14f3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f6d697865726170692f636f6c6c656374696f6e2d766965772e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/mixerapi/collection-view)[![Build](https://github.com/mixerapi/mixerapi-dev/workflows/Build/badge.svg?branch=master)](https://github.com/mixerapi/mixerapi-dev/actions?query=workflow%3ABuild)[![Coverage Status](https://camo.githubusercontent.com/980eb71f87b8f84d118d946d1a90203dbc53bbc8ac87363bc543899b32c0d2a0/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6d697865726170692f6d697865726170692d6465762f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/mixerapi/mixerapi-dev?branch=master)[![MixerApi](https://camo.githubusercontent.com/bca1ea90642661e0908fc7ad1c1cdbd704cda1063a2cb40801fab9d0ccdbd6af/68747470733a2f2f6d697865726170692e636f6d2f6173736574732f696d672f6d697865722d6170692d7265642e737667)](https://mixerapi.com)[![CakePHP](https://camo.githubusercontent.com/21b7bf61684c39eabf40bb424dd733f6f3a4bd11de430f8accc24ba0445b4b9b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f63616b657068702d253545342e322d7265643f6c6f676f3d63616b65706870)](https://book.cakephp.org/4/en/index.html)[![Minimum PHP Version](https://camo.githubusercontent.com/7f2179949cf3def20f5d08c400d94cf1c6c68c30bdaa05546c78e33eccded56f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d253545382e302d3838393242462e7376673f6c6f676f3d706870)](https://php.net/)

A simple Collection View for displaying configurable pagination meta data in JSON or XML collection responses. Read more at [MixerAPI.com](https://mixerapi.com).

Installation
------------

[](#installation)

!!! info "" You can skip this step if MixerAPI is installed. However, you will still new to define your viewClasses (read below).

```
composer require mixerapi/collection-view
bin/cake plugin load MixerApi/CollectionView
```

Alternatively after composer installing you can manually load the plugin in your Application:

```
# src/Application.php
public function bootstrap(): void
{
    // other logic...
    $this->addPlugin('MixerApi/CollectionView');
}
```

Setup
-----

[](#setup)

Your controllers must define their [view classes for content negotiation](https://book.cakephp.org/5/en/views/json-and-xml-views.html#defining-view-classes-to-negotiate-with).

```
use MixerApi\CollectionView\View\JsonCollectionView;
use MixerApi\CollectionView\View\XmlCollectionView;

public function viewClasses(): array
{
    return [JsonCollectionView::class, XmlCollectionView::class];
}
```

This can be done in your AppController to add them to all inheriting controllers or on a controller-by-controller basis.

Usage
-----

[](#usage)

That's it, you're done. Perform `application/xml` or `application/json` requests as normal. You may also request by `.xml` or `.json` extensions (assuming you've enabled them in your `config/routes.php`). This plugin will only modify collections (e.g. controller::index action) requests, not item (e.g. controller::view action) requests.

JSON sample```
{
    "collection": {
        "url": "/films?page=3&direction=desc",
        "count": 20,
        "total": 1000,
        "pages": 50,
        "next": "/films?page=4",
        "prev": "/films?page=2",
        "first": "/films",
        "last": "/films?page=50"
    },
    "data": [
        {
            "id": 1,
            "first_name": "PENELOPE",
            "last_name": "GUINESS",
            "modified": "2006-02-15T04:34:33+00:00",
            "films": [
                {
                    "id": 1,
                    "title": "ACADEMY DINOSAUR",
                    "description": "A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies",
                    "release_year": "2006",
                    "language_id": 1,
                    "rental_duration": 6,
                    "length": 86,
                    "rating": "PG",
                    "special_features": "Deleted Scenes,Behind the Scenes",
                    "modified": "2006-02-15T05:03:42+00:00"
                }
            ]
        }
    ]
}
```

XML sample```

    /films?page=3&amp;direction=desc
    20
    1000
    50
    /films?page=4
    /films?page=2
    /films
    /films?page=50

    1
    PENELOPE
    GUINESS
    2/15/06, 4:34 AM

      1
      ACADEMY DINOSAUR
      A Epic Drama of a Feminist And a Mad Scientist who must Battle a Teacher in The Canadian Rockies
      2006
      1
      6
      86
      PG
      Deleted Scenes,Behind the Scenes
      2/15/06, 5:03 AM

```

Configuration
-------------

[](#configuration)

This is optional. You can alter the names of the response keys, simply create a config/collection\_view.php file. Using the example below we can change the `collection` key to `pagination`, `data` to `items`, and alter some key names within our new pagination object. Just keep the mapped items `{{names}}` as-is.

```
# config/collection_view.php
return [
    'CollectionView' => [
        'pagination' => '{{collection}}', // array that holds pagination data
        'pagination.url' => '{{url}}', // url of current page
        'pagination.count' => '{{count}}', // items on the page
        'pagination.total' => '{{total}}', // total database records
        'pagination.pages' => '{{pages}}', // total pages
        'pagination.next' => '{{next}}', // next page url
        'pagination.prev' => '{{prev}}', // previous page url
        'pagination.first' => '{{first}}', // first page url
        'pagination.last' => '{{last}}', // last page url
        'items' => '{{data}}', // the collection of data
    ]
];
```

###  Health Score

55

—

FairBetter than 98% of packages

Maintenance84

Actively maintained with recent releases

Popularity32

Limited adoption so far

Community12

Small or concentrated contributor base

Maturity74

Established project with proven stability

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~61 days

Recently: every ~182 days

Total

33

Last Release

92d ago

Major Versions

v0.3.0 → v1.0.02022-01-16

v1.1.7 → v2.0.02024-02-17

PHP version history (3 changes)v0.1.0PHP &gt;=7.2

v1.0.0PHP ^8.0

v2.0.0PHP ^8.1

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/171294?v=4)[Chris Nizzardini](/maintainers/cnizzardini)[@cnizzardini](https://github.com/cnizzardini)

---

Top Contributors

[![cnizzardini](https://avatars.githubusercontent.com/u/171294?v=4)](https://github.com/cnizzardini "cnizzardini (31 commits)")

---

Tags

cakephpcollectionsjsonpaginationserializationxmlcakephpcakephp viewcakephp json

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mixerapi-collection-view/health.svg)

```
[![Health](https://phpackages.com/badges/mixerapi-collection-view/health.svg)](https://phpackages.com/packages/mixerapi-collection-view)
```

###  Alternatives

[cakephp/bake

Bake plugin for CakePHP

11211.2M158](/packages/cakephp-bake)[dereuromark/cakephp-tools

A CakePHP plugin containing lots of useful and reusable tools

338920.1k32](/packages/dereuromark-cakephp-tools)[dereuromark/cakephp-queue

The Queue plugin for CakePHP provides deferred task execution.

308850.3k14](/packages/dereuromark-cakephp-queue)[dereuromark/cakephp-ide-helper

CakePHP IdeHelper Plugin to improve auto-completion

1862.1M27](/packages/dereuromark-cakephp-ide-helper)[dereuromark/cakephp-tinyauth

A CakePHP plugin to handle user authentication and authorization the easy way.

129228.6k10](/packages/dereuromark-cakephp-tinyauth)[cakephp/queue

Queue plugin for CakePHP

36257.9k12](/packages/cakephp-queue)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
