PHPackages                             arturdoruch/list-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. arturdoruch/list-bundle

ActiveSymfony-bundle

arturdoruch/list-bundle
=======================

Symfony package for pagination, sorting and filtering of a list items.

0.2.3(4y ago)1185MITPHPPHP ^7.0

Since Dec 11Pushed 4y ago1 watchersCompare

[ Source](https://github.com/arturdoruch/list-bundle)[ Packagist](https://packagist.org/packages/arturdoruch/list-bundle)[ RSS](/packages/arturdoruch-list-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (1)Versions (17)Used By (0)

ListBundle
==========

[](#listbundle)

Symfony bundle for pagination, sorting and filtering of list items.

Bundle contains paginators supporting:

- array
- Doctrine\\ORM\\Query
- Doctrine\\ORM\\QueryBuilder
- Doctrine\\ODM\\MongoDB\\Query\\Query
- Doctrine\\ODM\\MongoDB\\Query\\Builder
- Doctrine\\MongoDB\\CursorInterface
- MongoCursor

For other database queries or cursors you can create own paginators. See [paginators](Resources/doc/bundle_configuration.md#paginators) configuration option.

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

[](#installation)

Run composer command

```
composer require arturdoruch/list-bundle
```

and register list-bundle and required other bundles in application Kernel class.

In Symfony 3

```
// app/AppKernel.php
public function registerBundles()
{
    $bundles = [
        // Other bundles
        new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
        new Symfony\Bundle\TwigBundle\TwigBundle(),
        new ArturDoruch\ListBundle\ArturDoruchListBundle(),
    ];
}
```

In Symfony &gt;= 4

```
// config/bundles.php
return [
    // Other bundles
    Symfony\Bundle\FrameworkBundle\FrameworkBundle::class => ['all' => true],
    Symfony\Bundle\TwigBundle\TwigBundle::class => ['all' => true],
    ArturDoruch\ListBundle\ArturDoruchListBundle::class => ['all' => true],
];
```

### JavaScript support

[](#javascript-support)

For JavaScript support install (with `yarn` or `npm`) package [@arturdoruch/list](https://github.com/arturdoruch/js-list). Package contains also file with CSS styles, styling the filter form and item list.

Bundle configuration
--------------------

[](#bundle-configuration)

See [bundle configuration options](Resources/doc/bundle_configuration.md).

Usage
-----

[](#usage)

In short:

1. [Create controller action getting the item list](#creating-controller-action-getting-the-item-list)
2. [Create template displaying item list](#creating-template-displaying-item-list)

### Controller

[](#controller)

#### Creating controller action getting the item list

[](#creating-controller-action-getting-the-item-list)

The controller action requirements:

- **The route method must be type of `GET`.**
- **To the twig template must be passed the `ArturDoruch\ListBundle\ItemList` object.**

Full example of the controller action getting book list:

```
