Laravel Resource Reducer - ShipSaaS

Optimizes your API responses and say no to BIT FAT JSON every time.

Ever thinking about how to speed up your application by optimizing the response?

Laravel Resource Reducer helps you to optimize every API request by:

  • Reduce the response's size, get what you need ⭐️

    • Defer execution and allow on-demand data

  • Responses to consumers faster 🚀

    • No more BIG FAT JSON every item/request

  • Computation only starts when required, save CPU & memory 😎

  • Built-in relationship access by using dot notation 👀

  • Eager-loading on steroids (automated eager-loading, no more N+1 pain) 🔋

A simple yet super effective method to skyrocketing your API responding times 🥰

The Inspiration

If you know about GraphQL query, in order to query for data, we have to define which fields we want to acquire (not a YOLO response, lol)

Isn't that lovely?

Laravel Resource stands as the transformation layer and is highly reusable. But, the performance is not so good.

Imagine for a simple dropdown of Users, we'll use UserResource and it would return a lot of unnecessary fields. It takes more memory, and CPU utilization (and is slow).

And with Laravel Resource Reducer, you get what you ask for 😎 and fast.

Simple Usage

GET v1/users?_f=id,name

{
    "data": [
        {
            "id": 1,
            "name": "Seth Phat from ShipSaaS"
        },
        {
            "id": 2,
            "name": "Awesome userland"
        }
    ]
}

GET v1/users?_f[]=id&_f[]=name&_f[]=articles.name

{
    "data": [
        {
            "id": 1,
            "name": "Seth Phat from ShipSaaS"
            "articles": [
                {
                    "name": "The Laravel Resource Reducer"
                }
            ]
        },
        {
            "id": 2,
            "name": "Awesome userland",
            "articles": []
        }
    ]
}

Demo

Coming soon <3

Last updated