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

ActiveSymfony-bundle[Utility &amp; Helpers](/categories/utility)

17734027950/pagerfanta-bundle
=============================

Bundle to use Pagerfanta with Symfony2

v1.1.2(8y ago)019MITPHP

Since Apr 25Pushed 8y agoCompare

[ Source](https://github.com/17734027950/pagerfanta-bundle)[ Packagist](https://packagist.org/packages/17734027950/pagerfanta-bundle)[ RSS](/packages/17734027950-pagerfanta-bundle/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (6)Versions (2)Used By (0)

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 kernel:

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

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') }}

```

### 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.

License
-------

[](#license)

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

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

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

Unknown

Total

1

Last Release

2937d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/791fca28f461dbd00e2e06eee214ce6e1140dce8f5fd84f3fed6622098b676d3?d=identicon)[17734027950](/maintainers/17734027950)

---

Top Contributors

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

---

Tags

pagepaging

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[sylius/sylius

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

8.4k5.6M650](/packages/sylius-sylius)[pentatrion/vite-bundle

Vite integration for your Symfony app

2725.3M13](/packages/pentatrion-vite-bundle)[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)[beberlei/porpaginas

Library that generically solves several pagination issues with DAO/repository abstractions.

163612.6k11](/packages/beberlei-porpaginas)[netgen/content-browser

Netgen Content Browser is a Symfony bundle that provides an interface which selects items from any kind of backend and returns the IDs of selected items back to the calling code.

14112.1k8](/packages/netgen-content-browser)[leapt/core-bundle

Symfony LeaptCoreBundle

2529.1k4](/packages/leapt-core-bundle)

PHPackages © 2026

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