PHPackages                             aejnsn/lapis - 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. [API Development](/categories/api)
4. /
5. aejnsn/lapis

ActiveLibrary[API Development](/categories/api)

aejnsn/lapis
============

An API toolkit for Laravel 5.5+

0.2.0(6y ago)2193[1 issues](https://github.com/aejnsn/lapis/issues)MITPHPPHP &gt;=7.0.0

Since Oct 17Pushed 6y ago2 watchersCompare

[ Source](https://github.com/aejnsn/lapis)[ Packagist](https://packagist.org/packages/aejnsn/lapis)[ RSS](/packages/aejnsn-lapis/feed)WikiDiscussions master Synced 2mo ago

READMEChangelog (2)Dependencies (5)Versions (3)Used By (0)

###  [![lapis](https://user-images.githubusercontent.com/5347897/31596692-2a79a572-b212-11e7-924c-356187b8ea7c.png)](https://github.com/aejnsn/lapis)

[](#--)

#### A toolkit building on API Resources in Laravel.

[](#a-toolkit-building-on-api-resources-in-laravel)

 [![Build Status](https://camo.githubusercontent.com/d270fbe0ceb9a74a13bed44cc3299fec63edcd383170d5adcfcd9b59eaabd181/68747470733a2f2f7472617669732d63692e6f72672f61656a6e736e2f6c617069732e7376673f6272616e63683d6d6173746572)](https://travis-ci.org/aejnsn/lapis) [![Coverage Status](https://camo.githubusercontent.com/aa000b529f0580a994bbb1b5bea6135eebb1d86bbd2b478e650624e84d994243/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f61656a6e736e2f6c617069732f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/aejnsn/lapis?branch=master) [![](https://camo.githubusercontent.com/1151bd4dfa9090ecb778898c3575e6608a5843343aa2429465dbfd0b8150dbf5/68747470733a2f2f6170692e636f6465636c696d6174652e636f6d2f76312f6261646765732f31326230653531666133306630616461613965612f6d61696e7461696e6162696c697479)](https://codeclimate.com/github/aejnsn/lapis/maintainability)

---

### Concept

[](#concept)

RESTful API endpoints typically require more functionality than pagination alone. For example, a front-end or mobile application may implement a filtering scheme or require access to the endpoint's nested resources. Lapis intends to provide a lightweight filtering and nested resource pattern leveraging the existing facilities in Laravel 5.5.

#### Includes

[](#includes)

Let's say we have an endpoint in a blogging platform to list our `post` resources returning a response like so:
`GET https://api.myrecipeblog.com/posts`

```
{
  "posts": [
    {
      "name": "Asparagus Steak Oscar",
      "category": "food",
      "postedAt": "2017-09-12 16:04:33",
      "authorId": 14
    },
    {
      "name": "Churchill Downs Mint Julep",
      "category": "drinks",
      "postedAt": "2017-10-05 18:32:12",
      "authorId": 15
    }
  ]
}
```

Ideally we would want to see details of a post's author in our front-end. Right, so make another request to a hypothetical `users` endpoint referencing a distinct list of authorIds from the `posts` response...No, absolutely not! We (hopefully) spent the time in our blogging platform's backend to model our data's relationships and set up foreign key constraints with appropriate indices. So let's put those models to work.

Lapis, leveraging Laravel's API Resources, allows us to add an `include` parameter on our request URL to retrieve the nested `author` (User) relationship. Our request URL and response would look something like this:

`GET https://api.myrecipeblog.com/posts?include=author`

```
{
  "posts": [
    {
      "name": "Asparagus Steak Oscar",
      "category": "food",
      "postedAt": "2017-09-12 16:04:33",
      "authorId": 14,
      "author": {
        "id": 14,
        "name": "John Doe",
        "forHire": true,
        "chefRating": 5
      }
    },
    {
      "name": "Churchill Downs Mint Julep",
      "category": "drinks",
      "postedAt": "2017-10-05 18:32:12",
      "authorId": 15,
      "author": {
        "id": 15,
        "name": "James Smith",
        "forHire": false,
        "chefRating": 1
      }
    }
  ]
}
```

##### Nested Includes

[](#nested-includes)

This will also work for nested relationships. For example, if our `User` model contained a `favorites` relationship we could request `GET https://api.myrecipeblog.com/posts?include=author.favorites`and an array of the author's `favorites` would be nested inside the `author` object.

#### Filtering

[](#filtering)

Let's go back to our original response above, for which we called the `posts` endpoint. Maybe we only want to see posts from the drinks category. We could alter our call from above like so:

`GET https://api.myrecipeblog.com/posts?filter[category]=drinks`

```
{
  "posts": [
    {
      "name": "Churchill Downs Mint Julep",
      "category": "drinks",
      "postedAt": "2017-10-05 18:32:12",
      "authorId": 15
    }
  ]
}
```

We can also specify multiple filters using this structure:

`GET https://api.myrecipeblog.com/posts?filter[category]=drinks&filter[authorId]=15`

##### Nested Filters

[](#nested-filters)

We discussed including an `author` relationship above. We can also filter on the author's details by making a request like so:

`GET https://api.myrecipeblog.com/posts?filter[author.forHire]=true`

##### Filter Operators

[](#filter-operators)

Up until this point we've just used filters to assert a field is equal to a given value. Filters understand the concept of operators. Here are a few examples:

List posts later than October 1, 2017.

`GET https://api.myrecipeblog.com/posts?filter[postedAt{gte}]=2017-10-01`

List posts where the author's name starts with John.

`GET https://api.myrecipeblog.com/posts?filter[author.name{starts}]=John`

### Reference Implementation

[](#reference-implementation)

### Installation &amp; Usage

[](#installation--usage)

###  Health Score

22

—

LowBetter than 22% of packages

Maintenance10

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity49

Maturing project, gaining track record

 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 ~638 days

Total

2

Last Release

2488d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/68cde9bed78ae189a253abf5a8ffe2cac7614a5df428c21e7a634648cec40119?d=identicon)[aejnsn](/maintainers/aejnsn)

---

Top Contributors

[![aejnsn](https://avatars.githubusercontent.com/u/5347897?v=4)](https://github.com/aejnsn "aejnsn (23 commits)")

---

Tags

apifilteringlaravelapilaravelfilteringtoolkit

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/aejnsn-lapis/health.svg)

```
[![Health](https://phpackages.com/badges/aejnsn-lapis/health.svg)](https://phpackages.com/packages/aejnsn-lapis)
```

###  Alternatives

[essa/api-tool-kit

set of tools to build an api with laravel

52680.5k](/packages/essa-api-tool-kit)[mollie/laravel-mollie

Mollie API client wrapper for Laravel &amp; Mollie Connect provider for Laravel Socialite

3624.1M28](/packages/mollie-laravel-mollie)

PHPackages © 2026

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