PHPackages                             muath-ye/laravel-paginateroute - 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. [Utility &amp; Helpers](/categories/utility)
4. /
5. muath-ye/laravel-paginateroute

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

muath-ye/laravel-paginateroute
==============================

Laravel outer extension to easily use laravel's paginator without the query string

2.7.0(7y ago)04MITPHPPHP &gt;=5.4.0

Since Jun 3Pushed 3y agoCompare

[ Source](https://github.com/muath-ye/laravel-paginateroute)[ Packagist](https://packagist.org/packages/muath-ye/laravel-paginateroute)[ Docs](https://github.com/spatie/laravel-paginateroute)[ RSS](/packages/muath-ye-laravel-paginateroute/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (5)Versions (26)Used By (0)

🚨 THIS PACKAGE HAS BEEN ABANDONED 🚨

We don't use this package anymore in our own projects and cannot justify the time needed to maintain it anymore. That's why we have chosen to abandon it. Feel free to fork our code and maintain your own copy.

Laravel Paginate Route
======================

[](#laravel-paginate-route)

[![Latest Version on Packagist](https://camo.githubusercontent.com/7ad2525b19511e61f0b406d092257cba8e606ec31ce1289f01f2e260ec045391/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7370617469652f6c61726176656c2d706167696e617465726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-paginateroute)[![Software License](https://camo.githubusercontent.com/55c0218c8f8009f06ad4ddae837ddd05301481fcf0dff8e0ed9dadda8780713e/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4d49542d627269676874677265656e2e7376673f7374796c653d666c61742d737175617265)](LICENSE.md)[![Build Status](https://camo.githubusercontent.com/89f6ec09b1540059d0f25422d958b636bcb54e2dde12a43d1e51cc71ff665f43/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7370617469652f6c61726176656c2d706167696e617465726f7574652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.org/spatie/laravel-paginateroute)[![Quality Score](https://camo.githubusercontent.com/003b861c5f90b86a7a4a78b905f72ba64144044578aad26d75ab395ac6515e04/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7370617469652f6c61726176656c2d706167696e617465726f7574652e7376673f7374796c653d666c61742d737175617265)](https://scrutinizer-ci.com/g/spatie/laravel-paginateroute)[![StyleCI](https://camo.githubusercontent.com/885641c6b00c4962164da302b78b37c834242e034ef7498e750467d8aa13bd31/68747470733a2f2f7374796c6563692e696f2f7265706f732f33363739313535352f736869656c643f6272616e63683d6d6173746572)](https://styleci.io/repos/36791555)[![Total Downloads](https://camo.githubusercontent.com/30cdd7c5c006cebab9794b79c9851496ead71273f1a992498c66a46bce53434d/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7370617469652f6c61726176656c2d706167696e617465726f7574652e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/spatie/laravel-paginateroute)

This package adds the `paginate` route method to support pagination via custom routes instead of query strings. This also allows for easily translatable pagination routes ex. `/news/page/2`, `/nieuws/pagina/2`.

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

**Note:** If you're upgrading to 2.0, check out the [upgrade guide](#upgrading) below.

Postcardware
------------

[](#postcardware)

You're free to use this package (it's [MIT-licensed](LICENSE.md)), but if it makes it to your production environment you are required to send us a postcard from your hometown, mentioning which of our package(s) you are using.

Our address is: Spatie, Samberstraat 69D, 2060 Antwerp, Belgium.

The best postcards will get published on the open source page on our website.

Install
-------

[](#install)

Via Composer

```
$ composer require spatie/laravel-paginateroute
```

First register the service provider and facade in your application.

```
// config/app.php

'providers' => [
    ...
    'Spatie\PaginateRoute\PaginateRouteServiceProvider',
];

'aliases' => [
    ...
    'PaginateRoute' => 'Spatie\PaginateRoute\PaginateRouteFacade',
];
```

Then register the macros in `App\Providers\RouteServiceProvider::boot()`.

```
// app/Providers/RouteServiceProvider.php

use PaginateRoute;

// ...

public function boot()
{
    PaginateRoute::registerMacros();

    parent::boot();
}
```

Usage
-----

[](#usage)

The `paginate` route macro will register two routes for you.

```
// app/Http/routes.php

// Generates /users & /users/page/{page}
Route::paginate('users', 'UsersController@index');
```

In your route's action you can just use Laravel's regular pagination methods.

```
// app/Http/Controllers/UsersController.php

public function index()
{
    return view('users.index', ['users' => \App\User::simplePaginate(5)]);
}
```

If you want to customize or add translations for the "page" url segment, you can publish the language files.

```
$ php artisan vendor:publish --provider="Spatie\PaginateRoute\PaginateRouteServiceProvider"
```

### Generating Url's

[](#generating-urls)

Since Laravel's paginator url's will still use a query string, PaginateRoute has it's own url generator and page helper functions.

```
{{-- $users is an instance of \Illuminate\Contracts\Pagination\Paginator --}}

@if(PaginateRoute::hasPreviousPage())
  Previous
@endif

@if(PaginateRoute::hasNextPage($users))
  Next
@endif

```

The `nextPage` functions require the paginator instance as a parameter, so they can determine whether there are any more records.

```
/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @return int|null
 */
public function nextPage(Paginator $paginator)
```

```
/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @return bool
 */
public function hasNextPage(Paginator $paginator)
```

```
/**
 * @param  \Illuminate\Contracts\Pagination\Paginator $paginator
 * @return string|null
 */
public function nextPageUrl(Paginator $paginator)
```

```
/**
 * @return int|null
 */
public function previousPage()
```

```
/**
 * @return bool
 */
public function hasPreviousPage()
```

```
/**
 * @param  bool $full
 * @return string|null
 */
public function previousPageUrl($full = false)
```

```
/**
 * @param int  $page
 * @param bool $full
 * @return string
 */
public function pageUrl($page, $full = false)
```

If `$full` is true, the first page will be a fully qualified url. Ex. `/users/page/1` instead if just `/users` (this is the default).

To retrieve the url of a specific page of a paginated route, that isn't the current route, there's the `addPageQuery` function.

```
/**
 * @param string $url
 * @param int $page
 * @param bool $full
 * @return string
 */
public function addPageQuery($url, $page, $full = false)
```

You can also retrieve an array with all available urls. These can be rendered as a plain html list with page numbers. Note that these functions require a `LengthAwarePaginator`.

```
/**
 * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
 * @param  bool $full
 * @return array
 */
public function allUrls(LengthAwarePaginator $paginator, $full = false)
```

```
/**
 * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
 * @param  bool $full
 * @param  string $class
 * @param  bool $additionalLinks
 * @return string
 */
public function renderPageList(LengthAwarePaginator $paginator, $full = false, $class = null, $additionalLinks = false)
```

```

    1
    2
    3
    4
    &raquo;

```

You can render link tags to mark previous and next page for SEO. Note that these functions require a `LengthAwarePaginator`.

```
/**
 * @param  \Illuminate\Contracts\Pagination\LengthAwarePaginator $paginator
 * @param  bool $full
 * @return string
 */
public function renderRelLinks(LengthAwarePaginator $paginator, $full = false)
```

```

```

Tests
-----

[](#tests)

The package contains some integration/smoke tests, set up with Orchestra. The tests can be run via phpunit.

```
$ phpunit

```

Upgrading
---------

[](#upgrading)

### 1.x =&gt; 2.0

[](#1x--20)

The 2.0 release changes the route macro to only register one route with the entire query in it, so providing a page parameter to the action link is no longer possible.

For example, `action('FooController@bar', ['page' => 3])` is no longer possible, and should be replaced by `PaginateRoute::addPageQuery(action('FooController@bar'), 3)`.

Changelog
---------

[](#changelog)

Please see [CHANGELOG](CHANGELOG.md) for more information what has changed recently.

Contributing
------------

[](#contributing)

Please see [CONTRIBUTING](CONTRIBUTING.md) for details.

Security
--------

[](#security)

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

Credits
-------

[](#credits)

- [Sebastian De Deyne](https://github.com/sebastiandedeyne)
- [All Contributors](../../contributors)

About Spatie
------------

[](#about-spatie)

Spatie is a webdesign agency in Antwerp, Belgium. You'll find an overview of all our open source projects [on our website](https://spatie.be/opensource).

License
-------

[](#license)

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

###  Health Score

29

—

LowBetter than 60% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity3

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity68

Established project with proven stability

 Bus Factor2

2 contributors hold 50%+ of commits

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

Recently: every ~61 days

Total

25

Last Release

2872d ago

Major Versions

1.6.1 → 2.0.02015-08-14

2.3.0 → 5.3.x-dev2017-01-27

PHP version history (2 changes)1.0.0PHP &gt;=5.5.0

1.1.0PHP &gt;=5.4.0

### Community

Maintainers

![](https://www.gravatar.com/avatar/66c9b114af377fd2400eb4737a18d5d6833a0ece6fc4f9d3b063000d50253f97?d=identicon)[muath-ye](/maintainers/muath-ye)

---

Top Contributors

[![sebastiandedeyne](https://avatars.githubusercontent.com/u/1561079?v=4)](https://github.com/sebastiandedeyne "sebastiandedeyne (62 commits)")[![freekmurze](https://avatars.githubusercontent.com/u/483853?v=4)](https://github.com/freekmurze "freekmurze (49 commits)")[![duckzland](https://avatars.githubusercontent.com/u/1064954?v=4)](https://github.com/duckzland "duckzland (10 commits)")[![jehadja](https://avatars.githubusercontent.com/u/17106547?v=4)](https://github.com/jehadja "jehadja (5 commits)")[![willemvb](https://avatars.githubusercontent.com/u/1336390?v=4)](https://github.com/willemvb "willemvb (3 commits)")[![lucasmichot](https://avatars.githubusercontent.com/u/513603?v=4)](https://github.com/lucasmichot "lucasmichot (2 commits)")[![ockle](https://avatars.githubusercontent.com/u/2755069?v=4)](https://github.com/ockle "ockle (2 commits)")[![hugofabricio](https://avatars.githubusercontent.com/u/425678?v=4)](https://github.com/hugofabricio "hugofabricio (2 commits)")[![Tjoosten](https://avatars.githubusercontent.com/u/5157609?v=4)](https://github.com/Tjoosten "Tjoosten (1 commits)")[![vinicius73](https://avatars.githubusercontent.com/u/1561347?v=4)](https://github.com/vinicius73 "vinicius73 (1 commits)")[![hulkur](https://avatars.githubusercontent.com/u/11457732?v=4)](https://github.com/hulkur "hulkur (1 commits)")[![FaridAghili](https://avatars.githubusercontent.com/u/8607021?v=4)](https://github.com/FaridAghili "FaridAghili (1 commits)")[![m1guelpf](https://avatars.githubusercontent.com/u/23558090?v=4)](https://github.com/m1guelpf "m1guelpf (1 commits)")[![muath-ye](https://avatars.githubusercontent.com/u/34031333?v=4)](https://github.com/muath-ye "muath-ye (1 commits)")

---

Tags

spatielaravelpaginationroutinglaravel-paginateroute

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/muath-ye-laravel-paginateroute/health.svg)

```
[![Health](https://phpackages.com/badges/muath-ye-laravel-paginateroute/health.svg)](https://phpackages.com/packages/muath-ye-laravel-paginateroute)
```

###  Alternatives

[spatie/laravel-data

Create unified resources and data transfer objects

1.7k28.9M627](/packages/spatie-laravel-data)[spatie/laravel-livewire-wizard

Build wizards using Livewire

4061.0M4](/packages/spatie-laravel-livewire-wizard)[michaloravec/laravel-paginateroute

Laravel outer extension to easily use laravel's paginator without the query string

1813.8k](/packages/michaloravec-laravel-paginateroute)[spatie/filament-simple-stats

Opinionated prebuilt stat widgets to quickly add to your Filament dashboards.

2317.9k](/packages/spatie-filament-simple-stats)

PHPackages © 2026

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