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

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

ttskch/pagerfanta-bundle
========================

Most easy and customizable way to use Pagerfanta with Symfony

1.1.1(6y ago)4468MITPHPPHP ^7.1.3

Since May 10Pushed 5y ago1 watchersCompare

[ Source](https://github.com/ttskch/TtskchPagerfantaBundle)[ Packagist](https://packagist.org/packages/ttskch/pagerfanta-bundle)[ RSS](/packages/ttskch-pagerfanta-bundle/feed)WikiDiscussions master Synced 2w ago

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

⚠️ No longer under maintenance
==============================

[](#️-no-longer-under-maintenance)

This bundle is no longer under maintenance on today. Please use [TtskchPaginatorBundle](https://github.com/ttskch/TtskchPagerfantaBundle) instead.

TtskchPagerfantaBundle
======================

[](#ttskchpagerfantabundle)

[![Travis (.com)](https://camo.githubusercontent.com/b5264cd000a316a3b41c04eeb17a06e2e2469ffd2a09dfbb37b80ba504f3953d/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f636f6d2f7474736b63682f5474736b6368506167657266616e746142756e646c652e7376673f7374796c653d666c61742d737175617265)](https://travis-ci.com/ttskch/TtskchPagerfantaBundle)[![Latest Stable Version](https://camo.githubusercontent.com/36046d2614b981dfa5876987b8c037e292f99f18157de73ce34d660c472a8920/68747470733a2f2f706f7365722e707567782e6f72672f7474736b63682f706167657266616e74612d62756e646c652f76657273696f6e3f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/ttskch/pagerfanta-bundle)[![Total Downloads](https://camo.githubusercontent.com/e610c10ba1d592b6bf5300825cf062ae0b0a066b489627f666b45e211fc35277/68747470733a2f2f706f7365722e707567782e6f72672f7474736b63682f706167657266616e74612d62756e646c652f646f776e6c6f6164733f666f726d61743d666c61742d737175617265)](https://packagist.org/packages/ttskch/pagerfanta-bundle)

Most easy and customizable way to use [Pagerfanta](https://github.com/whiteoctober/Pagerfanta) with Symfony.

Features
--------

[](#features)

Advantages compared to [WhiteOctoberPagerfantaBundle](https://github.com/whiteoctober/WhiteOctoberPagerfantaBundle):

- So **light weight**
- Customizable **twig-templated views**
- **Sortable link** feature
- Easy to use with **search form**
- Preset **bootstrap4 theme**

Demo
----

[](#demo)

You can easily try demo app like below on [demo branch](https://github.com/ttskch/TtskchPagerfantaBundle/tree/demo).

[![](https://user-images.githubusercontent.com/4360663/35521752-e1d22a98-055d-11e8-9b9f-b593a1eb218f.png)](https://user-images.githubusercontent.com/4360663/35521752-e1d22a98-055d-11e8-9b9f-b593a1eb218f.png)

Requirement
-----------

[](#requirement)

- PHP ^7.1.3
- Symfony ^4.0

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

[](#installation)

```
$ composer require ttskch/pagerfanta-bundle
```

```
// config/bundles.php

return [
    // ...
    Ttskch\PagerfantaBundle\TtskchPagerfantaBundle::class => ['all' => true],
];
```

Usage
-----

[](#usage)

```
// FooController.php

public function index(FooRepository $fooRepository, Context $context)
{
    $context->initialize('id');

    $queryBuilder = $fooRepository
        ->createQueryBuilder('f')
        ->orderBy(sprintf('f.%s', $context->criteria->sort), $context->criteria->direction)
    ;

    $adapter = new DoctrineORMAdapter($queryBuilder);
    $pagerfanta = new Pagerfanta($adapter);
    $pagerfanta
        ->setMaxPerPage($context->criteria->limit)
        ->setCurrentPage($context->criteria->page)
    ;

    return $this->render('index.html.twig', [
        'pagerfanta' => $pagerfanta,
    ]);
}
```

```
{# index.html.twig #}

{% set keys = ['id', 'name', 'email'] %}

        {% for key in keys %}
            {{ ttskch_pagerfanta_sortable(key) }}
        {% endfor %}

    {% for item in pagerfanta.getCurrentPageResults() %}

            {% for key in keys %}
                {{ attribute(item, key) }}
            {% endfor %}

    {% endfor %}

{{ ttskch_pagerfanta_pager(pagerfanta) }}
```

See [src/Twig/PagerfantaExtension.php](src/Twig/PagerfantaExtension.php) to learn more about twig functions.

### Sort with property of joined entity

[](#sort-with-property-of-joined-entity)

```
// FooController.php

// ...

$queryBuilder = $fooRepository
    ->createQueryBuilder('f')
    ->leftJoin('f.parent', 'p')
;

if (preg_match('/^parent\.(.+)$/', $context->criteria->sort, $m)) {
    $sort = sprintf('p.%s', $m[1]);
} else {
    $sort = sprintf('f.%s', $context->criteria->sort);
}

$queryBuilder->orderBy($sort, $context->criteria->direction);

// ...
```

```
{# index.html.twig #}

{# ... #}

{{ ttskch_pagerfanta_sortable(id) }}
{{ ttskch_pagerfanta_sortable(name) }}
{{ ttskch_pagerfanta_sortable(email) }}
{{ ttskch_pagerfanta_sortable(parent.id) }}

{# ... #}
```

### Configuring

[](#configuring)

```
$ bin/console config:dump-reference ttskch_pagerfanta
# Default configuration for extension with alias: "ttskch_pagerfanta"
ttskch_pagerfanta:
    page:
        name:                 page
        range:                5
    limit:
        name:                 limit
        default:              10
    sort:
        key:
            name:                 sort
        direction:
            name:                 direction

            # "asc" or "desc"
            default:              asc
    template:
        pager:                '@TtskchPagerfanta/pager/default.html.twig'
        sortable:             '@TtskchPagerfanta/sortable/default.html.twig'
```

### Customizing views

[](#customizing-views)

#### Use preset bootstrap4 theme

[](#use-preset-bootstrap4-theme)

Just configure bundle like below.

```
# config/packages/ttskch_pagerfanta.yaml

ttskch_pagerfanta:
    template:
        pager: '@TtskchPagerfanta/pager/bootstrap4.html.twig'
```

#### Use your own theme

[](#use-your-own-theme)

Create your own templates and configure bundle like below.

```
# config/packages/ttskch_pagerfanta.yaml

ttskch_pagerfanta:
    template:
        pager: 'your/own/pager.html.twig'
        sortable: 'your/own/sortable.html.twig'
```

### Using with search form

[](#using-with-search-form)

```
// FooCriteria.php

use Ttskch\PagerfantaBundle\Entity\Criteria;

class FooCriteria extends Criteria
{
    public $query;
}
```

```
// FooSearchType.php

use Symfony\Component\Form\Extension\Core\Type\SearchType;
use Symfony\Component\Form\FormBuilderInterface;
use Symfony\Component\OptionsResolver\OptionsResolver;
use Ttskch\PagerfantaBundle\Form\CriteriaType;

class FooSearchType extends CriteriaType
{
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        parent::buildForm($builder, $options);

        $builder
            ->add('query', SearchType::class)
        ;
    }

    public function configureOptions(OptionsResolver $resolver)
    {
        $resolver->setDefaults([
            'data_class' => FooCriteria::class,
            // if your app depends on symfony/security-csrf adding below is recommended
            // 'csrf_protection' => false,
        ]);
    }
}
```

```
// FooRepository.php

public function createQueryBuilderFromCriteria(FooCriteria $criteria)
{
    return $this->createQueryBuilder('f')
        ->where('f.name like :query')
        ->orWhere('f.email like :query')
        ->setParameter('query', sprintf('%%%s%%', str_replace('%', '\%', $criteria->query)))
        ->orderBy(sprintf('f.%s', $criteria->sort), $criteria->direction)
    ;
}
```

```
// FooController.php

public function index(FooRepository $fooRepository, Context $context)
{
    $context->initialize('id', FooCriteria::class, FooSearchType::class);

    $queryBuilder = $fooRepository->createQueryBuilderFromCriteria($context->criteria);

    $adapter = new DoctrineORMAdapter($queryBuilder);
    $pagerfanta = new Pagerfanta($adapter);
    $pagerfanta
        ->setMaxPerPage($context->criteria->limit)
        ->setCurrentPage($context->criteria->page)
    ;

    return $this->render('index.html.twig', [
        'form' => $context->form->createView(),
        'pagerfanta' => $pagerfanta,
    ]);
}
```

```
{# index.html.twig #}

{{ form(form, {action: path('index'), method: 'get'}) }}

{% set keys = ['id', 'name', 'email'] %}

        {% for key in keys %}
            {{ ttskch_pagerfanta_sortable(key) }}
        {% endfor %}

    {% for item in pagerfanta.getCurrentPageResults() %}

            {% for key in keys %}
                {{ attribute(item, key) }}
            {% endfor %}

    {% endfor %}

{{ ttskch_pagerfanta_pager(pagerfanta) }}
```

###  Health Score

29

—

LowBetter than 57% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity17

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity58

Maturing project, gaining track record

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

Total

3

Last Release

2342d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/4360663?v=4)[Takashi Kanemoto](/maintainers/ttskch)[@ttskch](https://github.com/ttskch)

---

Top Contributors

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

---

Tags

customizablepagerfantapaginationpaginatorsearchablesortablesymfonysymfonypaginatorpaginationsortablepagerfantasearchablecustomizable

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[easycorp/easyadmin-bundle

Admin generator for Symfony applications

4.3k17.5M378](/packages/easycorp-easyadmin-bundle)[symfony/web-profiler-bundle

Provides a development tool that gives detailed information about the execution of any request

2.3k156.8M1.2k](/packages/symfony-web-profiler-bundle)[kimai/kimai

Kimai - Time Tracking

4.8k8.7k1](/packages/kimai-kimai)[sulu/sulu

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

1.3k1.4M196](/packages/sulu-sulu)[ttskch/paginator-bundle

The most thin, simple and customizable paginator bundle for Symfony

1114.3k](/packages/ttskch-paginator-bundle)[2lenet/crudit-bundle

The easy like Crud'it Bundle.

1615.6k12](/packages/2lenet-crudit-bundle)

PHPackages © 2026

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