An open API service indexing awesome lists of open source software.

https://github.com/facile-it/paginator-bundle

Symfony2 Paginator Bundle
https://github.com/facile-it/paginator-bundle

pagination-bundle paginator php symfony2-pagination

Last synced: 3 months ago
JSON representation

Symfony2 Paginator Bundle

Awesome Lists containing this project

README

          

A **lightweight** symfony2 pagination system

[![Build Status](https://travis-ci.org/facile-it/paginator-bundle.svg?branch=master)](https://travis-ci.org/facile-it/paginator-bundle)
[![Code Climate](https://codeclimate.com/github/facile-it/paginator-bundle/badges/gpa.svg)](https://codeclimate.com/github/facile-it/paginator-bundle)

## Requirements:

- Twig`>=1.5` version is required if you plan to include the twig template.
- Twig `2.*` is allowed

## Features:

- Inizialization can be made via request or via setters
- Handle route as well as route parameters

## Installation and configuration:

Quite easy [Composer](http://packagist.org), add:

```json
{
"require": {
"facile-it/paginator-bundle": "dev-master"
}
}
```

Or if you want to clone the repos:

git clone git://github.com/facile-it/paginator-bundle.git vendor/facile-it/PaginatorBundle

### Add PaginatorBundle to your application kernel

```php
// app/AppKernel.php
public function registerBundles()
{
return array(
// ...
new Facile\PaginatorBundle\FacilePaginatorBundle(),
// ...
);
}
```

## Usage examples:

### Controller

Currently paginator can paginate:

- `Doctrine\ORM\QueryBuilder`

```php
// Acme\MainBundle\Controller\ProductController.php

$queryBuilder = $this
->get('doctrine.orm.entity_manager')
->getRepository('AcmeMainBundle:Product')
->createQueryBuilder('product')

$paginator = $this->get('facile.paginator')->parseRequest($this->getRequest());

return $this->render('AcmeMainBundle:Product:list.html.twig', array(
'results' => $pagination,
'paginationInfo' => $paginator->getPaginationInfo($filterBuilder
)
);

```

### View

```jinja

{# display results #}

{% for product in results %}

{{ product.id }}
{{ product.title }}

{% endfor %}

{# display navigation #}

```