PHPackages                             white-october/pagerfanta-bundle - 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. white-october/pagerfanta-bundle

Abandoned → [babdev/pagerfanta-bundle](/?search=babdev%2Fpagerfanta-bundle)ArchivedSymfony-bundle[Utility &amp; Helpers](/categories/utility)

white-october/pagerfanta-bundle
===============================

Bundle to use Pagerfanta with Symfony2

v1.3.2(6y ago)46411.7M—9%113[13 issues](https://github.com/sampart/WhiteOctoberPagerfantaBundle/issues)[1 PRs](https://github.com/sampart/WhiteOctoberPagerfantaBundle/pulls)20MITPHPPHP &gt;=5.3.3

Since Jun 6Pushed 5y ago30 watchersCompare

[ Source](https://github.com/sampart/WhiteOctoberPagerfantaBundle)[ Packagist](https://packagist.org/packages/white-october/pagerfanta-bundle)[ RSS](/packages/white-october-pagerfanta-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (7)Versions (27)Used By (20)

This project is no longer maintained. If you are using it with Symfony 3.4, 4.4 or 5, you may want to use [this fork](https://github.com/BabDev/BabDevPagerfantaBundle) instead.

WhiteOctoberPagerfantaBundle
============================

[](#whiteoctoberpagerfantabundle)

[![Build Status](https://camo.githubusercontent.com/04b5e180b3d44ded87f2b5a90d144ba936fd909915104e65d67827d7ab7aa2fa/68747470733a2f2f7472617669732d63692e6f72672f77686974656f63746f6265722f57686974654f63746f626572506167657266616e746142756e646c652e706e673f6272616e63683d6d6173746572)](https://travis-ci.org/whiteoctober/WhiteOctoberPagerfantaBundle) [![Scrutinizer Quality Score](https://camo.githubusercontent.com/2ac1c689636c515f003df4062779dc1b663fa3adcb55835896808a52436c1f38/68747470733a2f2f7363727574696e697a65722d63692e636f6d2f672f77686974656f63746f6265722f57686974654f63746f626572506167657266616e746142756e646c652f6261646765732f7175616c6974792d73636f72652e706e673f733d35626263393930623863303562376463633639636430636665376438643436653939343463353330)](https://scrutinizer-ci.com/g/whiteoctober/WhiteOctoberPagerfantaBundle/) [![SensioLabsInsight](https://camo.githubusercontent.com/ff4b9cb7a4a3d5f13093f57b5a82657a087d65c7d4494d214bd96a85df3681bb/68747470733a2f2f696e73696768742e73656e73696f6c6162732e636f6d2f70726f6a656374732f65303833383338332d316338642d343036662d393837342d6137366330386237643231372f6d696e692e706e67)](https://insight.sensiolabs.com/projects/e0838383-1c8d-406f-9874-a76c08b7d217)

Bundle to use [Pagerfanta](https://github.com/whiteoctober/Pagerfanta) with [Symfony](https://github.com/symfony/symfony).

**Note:** If you are using a 2.0.x release of Symfony2, please use the `symfony2.0` branch of this bundle. The master branch of this bundle tracks the Symfony master branch.

The bundle includes:

- Twig function to render pagerfantas with views and options.
- Way to use easily views.
- Way to reuse options in views.
- Basic CSS for the DefaultView.

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

[](#installation)

1. Use [Composer](https://getcomposer.org/) to download the library

```
php composer.phar require white-october/pagerfanta-bundle

```

2. Then add the WhiteOctoberPagerfantaBundle to your application:

In Symfony &lt; 4:

```
// app/AppKernel.php
public function registerBundles()
{
    return array(
        // ...
        new WhiteOctober\PagerfantaBundle\WhiteOctoberPagerfantaBundle(),
        // ...
    );
}
```

In Symfony 4 with Symfony Flex this will be done automatically for you.

3. Configure and use things!

A) **Creating a Pager** is shown on the [Pagerfanta](https://github.com/whiteoctober/Pagerfanta) documentation. If you're using the Doctrine ORM, you'll want to use the [DoctrineORMAdapter](https://github.com/whiteoctober/Pagerfanta#doctrineormadapter)

B) **Rendering in Twig** is shown below in the [Rendering Pagerfantas](#rendering-pagerfantas) section.

C) **Configuration** is shown through this document

Rendering Pagerfantas
---------------------

[](#rendering-pagerfantas)

First, you'll need to pass an instance of Pagerfanta as a parameter into your template. For example:

```
$adapter = new DoctrineORMAdapter($queryBuilder);
$pagerfanta = new Pagerfanta($adapter);
return $this->render('@YourApp/Main/example.html.twig', [
    'my_pager' => $pagerfanta,
]);
```

You then call the the Pagerfanta Twig extension, passing in the Pagerfanta instance. The routes are generated automatically for the current route using the variable "page" to propagate the page number. By default, the bundle uses the *DefaultView* with the *default* name. The default syntax is:

```

    {{ pagerfanta(my_pager) }}

```

By default, the "page" variable is also added for the link to the first page. To disable the generation of `?page=1` in the url, simply set the `omitFirstPage` option to `true` when calling the `pagerfanta` twig function:

```
{{ pagerfanta(my_pager, 'default', { 'omitFirstPage': true}) }}

```

You can omit template parameter to make function call shorter, default template will be used:

```
{{ pagerfanta(my_pager, { 'omitFirstPage': true }) }}

```

If you have multiple pagers on one page, you'll need to change the name of the `page` parameter. Here's an example:

```

    {{ pagerfanta(my_other_pager, 'default', {'pageParameter': '[page_other]'}) }}

```

Note the square brackets around `page_other`; this won't work without them.

### Twitter Bootstrap

[](#twitter-bootstrap)

The bundle also has a Twitter Bootstrap view.

For Bootstrap 2:

```

    {{ pagerfanta(my_pager, 'twitter_bootstrap') }}

```

For Bootstrap 3:

```

    {{ pagerfanta(my_pager, 'twitter_bootstrap3') }}

```

For Bootstrap 4:

```

    {{ pagerfanta(my_pager, 'twitter_bootstrap4') }}

```

### Custom template

[](#custom-template)

If you want to use a custom template, add another argument:

```

    {{ pagerfanta(my_pager, 'my_template') }}

```

With options:

```
{{ pagerfanta(my_pager, 'default', { 'proximity': 2}) }}
```

See the [Pagerfanta documentation](https://github.com/whiteoctober/Pagerfanta) for the list of possible parameters.

Rendering the page of items itself
----------------------------------

[](#rendering-the-page-of-items-itself)

The items can be retrieved using `currentPageResults`. For example:

```
{% for item in my_pager.currentPageResults %}

        {{ item.id }}

{% endfor %}
```

Translate in your language
--------------------------

[](#translate-in-your-language)

The bundle also offers two views to translate the *default* and the *twitter bootstrap* views.

```
{{ pagerfanta(my_pager, 'default_translated') }}

{{ pagerfanta(my_pager, 'twitter_bootstrap_translated') }}
```

Adding Views
------------

[](#adding-views)

The views are added to the container with the *pagerfanta.view* tag:

XML

```

```

YAML

```
services:
    pagerfanta.view.default:
        class: Pagerfanta\View\DefaultView
        public: false
        tags: [{ name: pagerfanta.view, alias: default }]
```

Reusing Options
---------------

[](#reusing-options)

Sometimes you want to reuse options of a view in your project, and you don't want to write them all the times you render a view, or you can have different configurations for a view and you want to save them in a place to be able to change them easily.

For this you have to define views with the special view *OptionableView*:

```
services:
    pagerfanta.view.my_view_1:
        class: Pagerfanta\View\OptionableView
        arguments:
            - @pagerfanta.view.default
            - { proximity: 2, prev_message: Anterior, next_message: Siguiente }
        public: false
        tags: [{ name: pagerfanta.view, alias: my_view_1 }]
    pagerfanta.view.my_view_2:
        class: Pagerfanta\View\OptionableView
        arguments:
            - @pagerfanta.view.default
            - { proximity: 5 }
        public: false
        tags: [{ name: pagerfanta.view, alias: my_view_2 }]
```

And using then:

```
{{ pagerfanta(my_pager, 'my_view_1') }}
{{ pagerfanta(my_pager, 'my_view_2') }}
```

The easiest way to render pagerfantas (or paginators!) ;)

Basic CSS for the default view
------------------------------

[](#basic-css-for-the-default-view)

The bundles comes with basic CSS for the default view so you can get started with a good paginator faster. Of course you can change it, use another one or create your own view.

```

```

Configuration
-------------

[](#configuration)

It's possible to configure the default view for all rendering in your configuration file:

```
white_october_pagerfanta:
    default_view: my_view_1
```

Making bad page numbers return a HTTP 500
-----------------------------------------

[](#making-bad-page-numbers-return-a-http-500)

Right now when the page is out of range or not a number, the server returns a 404 response by default. You can set the following parameters to different than default value `to_http_not_found` (ie. null) to show a 500 exception when the requested page is not valid instead.

```
// app/config/config.yml
white_october_pagerfanta:
    exceptions_strategy:
        out_of_range_page:        ~
        not_valid_current_page:   ~
```

More information
----------------

[](#more-information)

For more advanced documentation, check the [Pagerfanta documentation](https://github.com/whiteoctober/Pagerfanta/blob/master/README.md).

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

[](#contributing)

We welcome contributions to this project, including pull requests and issues (and discussions on existing issues).

If you'd like to contribute code but aren't sure what, the [issues list](https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle/issues) is a good place to start. If you're a first-time code contributor, you may find Github's guide to [forking projects](https://guides.github.com/activities/forking/) helpful.

All contributors (whether contributing code, involved in issue discussions, or involved in any other way) must abide by our [code of conduct](code_of_conduct.md).

Acknowledgements
----------------

[](#acknowledgements)

Pablo Díez () for most of the work on the first versions of this bundle.

This project was originally located at .

License
-------

[](#license)

Pagerfanta is licensed under the MIT License. See the LICENSE file for full details.

###  Health Score

52

—

FairBetter than 96% of packages

Maintenance19

Infrequent updates — may be unmaintained

Popularity66

Solid adoption and visibility

Community50

Growing community involvement

Maturity68

Established project with proven stability

 Bus Factor3

3 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 ~113 days

Recently: every ~90 days

Total

22

Last Release

2359d ago

Major Versions

v1.0.8 → 2.1.x-dev2017-07-21

PHP version history (2 changes)v1.1.3PHP &gt;=5.3

v1.3.0PHP &gt;=5.3.3

### Community

Maintainers

![](https://www.gravatar.com/avatar/1c17da250011e442e7feac090b0642495fe88d77490bbbd259c4b8fca886057f?d=identicon)[pablodip](/maintainers/pablodip)

![](https://www.gravatar.com/avatar/3004d961143812c87d7ef7ff2fe053baebe5902db9881a6f29406fff4702a478?d=identicon)[olorton](/maintainers/olorton)

![](https://www.gravatar.com/avatar/664733429c68e675ccc0bc85ad272c4e0dcae3f838abbf5a33d53b37deffdcec?d=identicon)[sampart](/maintainers/sampart)

---

Top Contributors

[![pablodip](https://avatars.githubusercontent.com/u/98504?v=4)](https://github.com/pablodip "pablodip (69 commits)")[![richsage](https://avatars.githubusercontent.com/u/231551?v=4)](https://github.com/richsage "richsage (17 commits)")[![SpacePossum](https://avatars.githubusercontent.com/u/10462973?v=4)](https://github.com/SpacePossum "SpacePossum (12 commits)")[![javiereguiluz](https://avatars.githubusercontent.com/u/73419?v=4)](https://github.com/javiereguiluz "javiereguiluz (10 commits)")[![GromNaN](https://avatars.githubusercontent.com/u/400034?v=4)](https://github.com/GromNaN "GromNaN (9 commits)")[![sampart](https://avatars.githubusercontent.com/u/1507328?v=4)](https://github.com/sampart "sampart (7 commits)")[![johnwards](https://avatars.githubusercontent.com/u/34269?v=4)](https://github.com/johnwards "johnwards (6 commits)")[![Skadabr](https://avatars.githubusercontent.com/u/2155693?v=4)](https://github.com/Skadabr "Skadabr (5 commits)")[![stof](https://avatars.githubusercontent.com/u/439401?v=4)](https://github.com/stof "stof (5 commits)")[![phibo23](https://avatars.githubusercontent.com/u/1328782?v=4)](https://github.com/phibo23 "phibo23 (3 commits)")[![sstok](https://avatars.githubusercontent.com/u/904790?v=4)](https://github.com/sstok "sstok (3 commits)")[![makasim](https://avatars.githubusercontent.com/u/143206?v=4)](https://github.com/makasim "makasim (3 commits)")[![bobvandevijver](https://avatars.githubusercontent.com/u/1835343?v=4)](https://github.com/bobvandevijver "bobvandevijver (3 commits)")[![andreybolonin](https://avatars.githubusercontent.com/u/2576509?v=4)](https://github.com/andreybolonin "andreybolonin (2 commits)")[![AntoineLemaire](https://avatars.githubusercontent.com/u/2025537?v=4)](https://github.com/AntoineLemaire "AntoineLemaire (2 commits)")[![antonioperic](https://avatars.githubusercontent.com/u/2453151?v=4)](https://github.com/antonioperic "antonioperic (2 commits)")[![aramalipoor](https://avatars.githubusercontent.com/u/1164589?v=4)](https://github.com/aramalipoor "aramalipoor (2 commits)")[![eloipoch](https://avatars.githubusercontent.com/u/159255?v=4)](https://github.com/eloipoch "eloipoch (2 commits)")[![Etheriq](https://avatars.githubusercontent.com/u/5667027?v=4)](https://github.com/Etheriq "Etheriq (2 commits)")[![helios-ag](https://avatars.githubusercontent.com/u/334907?v=4)](https://github.com/helios-ag "helios-ag (2 commits)")

---

Tags

pagerfantaphpsymfony-bundlepagepaging

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/white-october-pagerfanta-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/white-october-pagerfanta-bundle/health.svg)](https://phpackages.com/packages/white-october-pagerfanta-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k16.7M310](/packages/easycorp-easyadmin-bundle)[shopware/platform

The Shopware e-commerce core

3.3k1.5M3](/packages/shopware-platform)[sulu/sulu

Core framework that implements the functionality of the Sulu content management system

1.3k1.3M152](/packages/sulu-sulu)[prestashop/prestashop

PrestaShop is an Open Source e-commerce platform, committed to providing the best shopping cart experience for both merchants and customers.

9.0k15.4k](/packages/prestashop-prestashop)[netgen/layouts-core

Netgen Layouts enables you to build and manage complex web pages in a simpler way and with less coding. This is the core of Netgen Layouts, its heart and soul.

3689.4k10](/packages/netgen-layouts-core)

PHPackages © 2026

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