PHPackages                             chelout/offset-pagination - 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. chelout/offset-pagination

ActiveLibrary[API Development](/categories/api)

chelout/offset-pagination
=========================

Offset pagination made easy for Laravel

v1.2(6y ago)45.0k1[1 issues](https://github.com/chelout/laravel-offset-pagination/issues)[1 PRs](https://github.com/chelout/laravel-offset-pagination/pulls)1MITPHPPHP ^7.1.3

Since Feb 27Pushed 5y ago2 watchersCompare

[ Source](https://github.com/chelout/laravel-offset-pagination)[ Packagist](https://packagist.org/packages/chelout/offset-pagination)[ Docs](https://github.com/chelout/offset-pagination)[ RSS](/packages/chelout-offset-pagination/feed)WikiDiscussions master Synced 3d ago

READMEChangelog (7)Dependencies (5)Versions (9)Used By (1)

This package provides an offset based pagination already integrated with Laravel's [query builder](https://laravel.com/docs/master/queries) and [Eloquent ORM](https://laravel.com/docs/master/eloquent). It calculates the SQL query limits automatically by checking the requests GET parameters, and automatically builds the next and previous urls for you.

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

[](#installation)

You can install this package via composer using:

```
composer require chelout/offset-pagination
```

The package will automatically register itself.

### Config

[](#config)

To publish the config file to `config/offset_pagination.php` run:

```
php artisan vendor:publish --provider="Chelout\OffsetPagination\CursorPaginationServiceProvider" --tag="config"
```

This will publish the following [file](config/offset_pagination.php). You can customize default items per page and maximum items per page.

Basic Usage
-----------

[](#basic-usage)

### Paginating Query Builder Results

[](#paginating-query-builder-results)

```
public function index()
{
    $users = DB::table('users')->offsetPaginate();

    return $users;
}
```

### Paginating Eloquent Results

[](#paginating-eloquent-results)

```
$users = User::offsetPaginate(5);
```

Of course, you may call paginate after setting other constraints on the query, such as where clauses:

```
$users = User::where('votes', '>', 100)->offsetPaginate(5);
```

Or sorting your results:

```
$users = User::orderBy('id', 'desc')->offsetPaginate(5);
```

Displaying Pagination Results
-----------------------------

[](#displaying-pagination-results)

### Converting to JSON

[](#converting-to-json)

A basic return will transform the paginator to JSON and will have a result like this:

```
Route::get('api/v1/users', function () {
    return App\User::offsetPaginate();
});
```

Calling `api/v1` will output:

```
{
   "data": [
        {},
   ],
    "offset": 60,
    "offset": 60,
    "prev": 55,
    "next": 65,
    "limit": 5,
    "total": 100,
    "next_page_url": "https://example.com/api/v1/users?limit=5&offset=65",
    "prev_page_url": "https://example.com/api/v1/users?limit=5&offset=55"
}
```

### Using a Resource Collection

[](#using-a-resource-collection)

By default, Laravel's API Resources when using them as collections, they will output a paginator's metadata into `links` and `meta`.

```
    {
        "data":[
            {},
        ],
        "links": {
            "first": "https://example.com/api/v1/users",
            "last": "https://example.com/api/v1/users?offset=95",
            "prev": "https://example.com/api/v1/users?offset=55",
            "next": "https://example.com/api/v1/users?offset=65"
        },
        "meta": {
            "offset": 60,
            "prev": 55,
            "next": 65,
            "limit": 5,
            "total": 100
        },
    }
```

Testing
-------

[](#testing)

Run the tests with:

```
vendor/bin/phpunit
```

Credits
-------

[](#credits)

- [Viacheslav Ostrovskiy](https://github.com/chelout)
- All Contributors

License
-------

[](#license)

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

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance15

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity63

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

Recently: every ~123 days

Total

7

Last Release

2505d ago

Major Versions

0.1.0 → 1.0.02018-02-27

PHP version history (2 changes)0.1.0PHP &gt;=7.0.0

v1.2PHP ^7.1.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/60cfb609b4fa19a2a1688987c6bdd70fe01d7b1cc3ab826593bb5997dc1b926d?d=identicon)[chelout](/maintainers/chelout)

---

Top Contributors

[![chelout](https://avatars.githubusercontent.com/u/9196257?v=4)](https://github.com/chelout "chelout (18 commits)")

---

Tags

apilaravelpagination

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/chelout-offset-pagination/health.svg)

```
[![Health](https://phpackages.com/badges/chelout-offset-pagination/health.svg)](https://phpackages.com/packages/chelout-offset-pagination)
```

###  Alternatives

[essa/api-tool-kit

set of tools to build an api with laravel

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

Resend for Laravel

1191.4M6](/packages/resend-resend-laravel)[api-platform/laravel

API Platform support for Laravel

59126.4k6](/packages/api-platform-laravel)[simplestats-io/laravel-client

Client for SimpleStats!

4515.5k](/packages/simplestats-io-laravel-client)[dragon-code/laravel-json-response

Automatically always return a response in JSON format

1118.6k1](/packages/dragon-code-laravel-json-response)

PHPackages © 2026

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