PHPackages                             dvsouto/laravel-json-paginate - 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. dvsouto/laravel-json-paginate

ActiveLibrary[API Development](/categories/api)

dvsouto/laravel-json-paginate
=============================

Create json paginate for API in Laravel/Lumen

1.0.7(6y ago)21.2k1MITPHPPHP ^7.0.0

Since Jul 18Pushed 3y ago1 watchersCompare

[ Source](https://github.com/dvsouto/laravel-json-paginate)[ Packagist](https://packagist.org/packages/dvsouto/laravel-json-paginate)[ Docs](https://github.com/dvsouto/laravel-json-paginate)[ RSS](/packages/dvsouto-laravel-json-paginate/feed)WikiDiscussions master Synced 3w ago

READMEChangelogDependencies (1)Versions (11)Used By (0)

Laravel &amp; Lumen Json Paginate
=================================

[](#laravel--lumen-json-paginate)

In a vanilla Laravel application exists the method `paginate` in Query Builder (), that returns the results formated to front pagination.

This package adds a `jsonPaginate` method to the Eloquent query builder that listens the results in json format to use in API and show data in others applications.

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

[](#installation)

You can install the package via composer:

```
composer require dvsouto/laravel-json-paginate
```

In Laravel 5.5 and above the service provider will automatically get registered. In older versions of the framework just add the service provider in `config/app.php` file:

```
'providers' => [
    ...
    Bitnary\JsonPaginate\JsonPaginateServiceProvider::class, // Bitnary JsonPaginate for o Eloquent
];
```

In Lumen you need to load de service provider on `bootstrap/app.php` file:

```
    ...
    $app->register(Bitnary\JsonPaginate\JsonPaginateServiceProvider::class); // Bitnary JsonPaginate for o Eloquent
```

Usage
-----

[](#usage)

To paginate the results prepared to return from API, simply call the `jsonPaginate` method.

```
YourModel::jsonPaginate();
```

Of course you may still use all the builder methods you know:

```
YourModel::where('my_field', 'myValue')->jsonPaginate();
```

By default the maximum page size is set to 100. You can change this number passing the value to `jsonPaginate`. You also pass the each side parameter to method for generate the page keys.

```
$per_page = 10; // 10 Results per page
$each_side = 3; // 3 buttons on each side

YourModel::jsonPaginate($per_page, $each_side);
```

By default the maximum page size is set to 100. You can change this number passing the value to `jsonPaginate`.

```
$maxResults = 10;

YourModel::jsonPaginate($maxResults);
```

This return an array containing thats parameters:

```
{
    "data": [ // (object) Results for this page
        {
            "id": 1,
            "name": "Davi Souto"
        },
        {
            "id": 2,
            "name": "Lorem Ipsum"
        },
        {
            "id": 3,
            "name": "Sit Amet"
        },
        ...
    ],
    "paginator": {
        "current_page": 1, // (int) Current page number
        "prev_page": 1, // (int) Previous page number
        "next_page": 2, // (int) Next page number
        "first_page": 1, // (int) The first page (always 1),
        "is_first_page": true, // (boolean) Is in first page ?
        "last_page": 25, // (int) Last page number
        "is_last_page": false, // (boolean) Is in last page ?
        "page_keys": [ // (array) Contains the list of pages to display in front
            1,
            2,
            3,
            4,
        ],
        "from_item": 1, // (int) Results for this page starts from this item
        "to_item": 100, // (int) Results for this page ends in this item
        "total_items": 100, // (int) Total of existent itens
        "per_page": 10, // (int) Results for this page ends in this item
        "display_items": // (int) Total of itens in this page
    }
}
```

Security
--------

[](#security)

If you discover any security related issues, please email  instead of using the issue tracker.

Credits
-------

[](#credits)

- [Spatie Laravel Json Api Paginate](https://github.com/spatie/laravel-json-api-paginate)
- [All Contributors](../../contributors)

License
-------

[](#license)

The MIT License (MIT). Please see [License File](LICENCE.md) for more information.

###  Health Score

30

—

LowBetter than 62% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity19

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity60

Established project with proven stability

 Bus Factor1

Top contributor holds 90.9% 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 ~54 days

Recently: every ~80 days

Total

7

Last Release

2213d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b4a8707e07e33449d5ec6a5958adc2765c57f8041de5b912ea30480187224d2b?d=identicon)[dvsouto](/maintainers/dvsouto)

---

Top Contributors

[![dvsouto](https://avatars.githubusercontent.com/u/16228821?v=4)](https://github.com/dvsouto "dvsouto (20 commits)")[![chimemoo](https://avatars.githubusercontent.com/u/34398865?v=4)](https://github.com/chimemoo "chimemoo (1 commits)")[![RafaelRodriguesUnioit](https://avatars.githubusercontent.com/u/157052245?v=4)](https://github.com/RafaelRodriguesUnioit "RafaelRodriguesUnioit (1 commits)")

---

Tags

laravellaravel-json-paginatelumenlumen-json-paginatepaginatedvsoutolaravel-json-paginatebitnarylumen-json-paginatelaravel-api-json-paginatelumen-api-json-paginate

### Embed Badge

![Health badge](/badges/dvsouto-laravel-json-paginate/health.svg)

```
[![Health](https://phpackages.com/badges/dvsouto-laravel-json-paginate/health.svg)](https://phpackages.com/packages/dvsouto-laravel-json-paginate)
```

###  Alternatives

[defstudio/telegraph

A laravel facade to interact with Telegram Bots

815320.5k3](/packages/defstudio-telegraph)[riclep/laravel-storyblok

A Laravel wrapper around the Storyblok API to provide a familiar experience for Laravel devs

6277.0k5](/packages/riclep-laravel-storyblok)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.1k1](/packages/jasara-php-amzn-selling-partner-api)[rapidez/core

Rapidez Core

1822.4k65](/packages/rapidez-core)

PHPackages © 2026

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