PHPackages                             earthit/cmip-rest - 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. earthit/cmip-rest

ActiveLibrary

earthit/cmip-rest
=================

Collection-Modifiers-ID-Property REST framework

2.1.2(10mo ago)216.2k↑160.9%1[2 issues](https://github.com/EarthlingInteractive/PHPCMIPREST/issues)1MITPHPPHP &gt;=8.1

Since Feb 18Pushed 10mo ago14 watchersCompare

[ Source](https://github.com/EarthlingInteractive/PHPCMIPREST)[ Packagist](https://packagist.org/packages/earthit/cmip-rest)[ RSS](/packages/earthit-cmip-rest/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (6)Versions (158)Used By (1)

[![Build Status](https://camo.githubusercontent.com/32e60b6a820ad85875dc0c791deb594e23445b9811535126e9a1f1ef210ec467/68747470733a2f2f7472617669732d63692e6f72672f45617274686c696e67496e7465726163746976652f504850434d4950524553542e7376673f6272616e63683d73746f72616765)](https://travis-ci.org/EarthlingInteractive/PHPCMIPREST)

CMIP REST
=========

[](#cmip-rest)

Handles CMIP-style (see below) REST requests using a schema definition.

What the heck is CMIP
---------------------

[](#what-the-heck-is-cmip)

A convention for REST services.

URLs are of the form `/[;][/[/]]`, hence 'CMIP'.

It also supports some other styles, mapping them to the same underlying operations.

There are five basic operations: search, get, post, put, patch, delete.

- **GET** `/[;][?]` returns a list of objects in the collection. The exact subset returned is determined by the `` (see 'collection filters'), and the way each object is represented is determined by `` (see 'record modifiers').
- **GET** `/[;]/` returns a single object of the collection identified by *id*.
- **POST** `/` add new records to the collection. The new records are provided as a JSON-encoded list in the request. If items POSTed include primary keys, they may conflict with existing items, in which case those items are updated as if a **PATCH** was done on those items.
- **PUT** `//` replaces a record with the data given as JSON in the request content. Fields without values provided are reset to their defaults.
- **PATCH** `//` updates a record with data given as JSON in the request content. Fields not explicitly mentioned retain their old value.
- **DELETE** `//` deletes a record.
- **DELETE** `/?` deletes records matching a filter.

### Record modifiers

[](#record-modifiers)

Modifiers indicate how to structure the resulting objects. The `with` modifier is a comma-separated list indicating what related objects should be returned with each record. A path like `/authors;with=books` would indicate to return a list of books with each author record, whereas a path like `/books;with=author,publisher` would indicate to return a single author and publisher with each book record. The set of related objects that may be requested is defined by the service, and services may provide alternate modifiers, possibly as aliases for long `with=` lists.

Additional levels of nesting may be requested by using a dot to separate path components. e.g. `/authors;with=books.publisher.postalAddress` to get a list of authors, each of which contains a list of all their books, each of which contains a 'publisher' record with a 'postalAddress' sub-record. The resulting JSON might look something like:

```
[
  {
    "id": 154,
    "name": "Some Author",
    "books": [
      {
        "id": 301,
        "title": "A Book Containing Words",
        "publisher": {
          "id": 4,
          "name": "Some Book Publishing Company",
          "postalAddress": {
            "streetAddress1": "450 Some Street",
            "localityName": "Someville",
            "regionCode": "SC",
            "postalCode": "12345"
            "countryCode": "USA",
          }
        }
      },
      ...more book records maybe go here...
    ]
  },
  ...more author records maybe go here...
]

```

### Collection filters

[](#collection-filters)

Except for a few reserved parameters, query parameters to a collection GET request correspond to fields of the items in the collection.

The reserved parameters are:

- `orderBy=[+-]...` - indicate sort order of results
- `limit=[,]` - indicate how many rows of the result set to skip and include

Field-matching parameter values may be in one of the following formats:

- `` - match a pattern where `*` stands for any substring. Only valid if the pattern does not contain a colon. May be optimized as an exact match if the given pattern doesn't contain any asterisks.
- `eq:` - match a value exactly
- `like:` - match a string based on a pattern, where `*` stands for any substring
- `lt:` - matches values less than that given
- `gt:` - matches values greater than that given
- `in:` - matches any value that is mentioned in the comma-separated list
- `is:null` - matches nulls
- `not:` - negate a filter, e.g. `not:is:null` or `not:like:*foo*`

Search parameters will be automatically parsed as appropriate given the field that they are matching on (e.g. if there is a field, `someNumericField` that is typed as containing a number, a seach for `someNumericField=eq:5` is interpreted as equals the number 5, not the string "5")

### Collection-Table mapping

[](#collection-table-mapping)

When translating a database record to its REST form, all primary key values are combined into a single `id`, with multiple fields separated by dashes.

When interpreting an ID given in a URL or in JSON, it must be converted to its component fields. Even if there really is only a single ID field int the database record, the ID data from JSON or the URL must be converted to the correct type.

Field names may be translated between naming conventions when loading and storing. The naming convention for tables and columns in Postgres seems to be to use squishedtogetherlowercase.

In the view exposed by the REST services:

- collection name is dash-separated (e.g. `patient-stays`)
- field names, both in the URL (modifiers and search parameters) and in request/response JSON data, are camelCase (e.g. `patientAdmissionDate`)

It is a goal of this project to make it simple to override these conventions and to allow special cases for different views of things. e.g. a class may be exposed as `super-duper-car-washes`, but the backing table actually be called `x_okaycarwash`.

TODO: Add example of using this library in PHP.

###  Health Score

47

—

FairBetter than 93% of packages

Maintenance38

Infrequent updates — may be unmaintained

Popularity26

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity90

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 97.8% 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 ~26 days

Recently: every ~136 days

Total

156

Last Release

304d ago

Major Versions

0.16.22 → 2.0.02024-01-08

PHP version history (4 changes)0.0.1PHP &gt;=5.2.0

0.0.84PHP ~5.2

0.1.0PHP &gt;=5.2

2.0.0PHP &gt;=8.1

### Community

Maintainers

![](https://www.gravatar.com/avatar/84f2846fb867825e6831a99f7ba5ca9301de56a424928e2c494f81c2c6061677?d=identicon)[TOGoS](/maintainers/TOGoS)

---

Top Contributors

[![TOGoS](https://avatars.githubusercontent.com/u/57142?v=4)](https://github.com/TOGoS "TOGoS (310 commits)")[![jrole0](https://avatars.githubusercontent.com/u/7505885?v=4)](https://github.com/jrole0 "jrole0 (7 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/earthit-cmip-rest/health.svg)

```
[![Health](https://phpackages.com/badges/earthit-cmip-rest/health.svg)](https://phpackages.com/packages/earthit-cmip-rest)
```

PHPackages © 2026

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