Download the PHP package ashleydawson/simple-pagination-bundle without Composer
On this page you can find all versions of the php package ashleydawson/simple-pagination-bundle. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download ashleydawson/simple-pagination-bundle
More information about ashleydawson/simple-pagination-bundle
Files in ashleydawson/simple-pagination-bundle
Package simple-pagination-bundle
Short Description Symfony bundle for Simple Pagination, the simple, lightweight and universal paginator that implements pagination on collections of things
License MIT
Informations about the package simple-pagination-bundle
Simple Pagination Bundle
Many thanks to BrowserStack for supporting open source projects like this one.
Symfony bundle for the Simple Pagination library.
Installation
You can install the Simple Pagination Bundle via Composer. To do that, simply require
the
package:
Run composer update
to install the package. Then you'll need to register the bundle in your app/AppKernel.php
:
Basic Usage
The simplest collection we can use the paginator service on is an array. Please see below for an extremely simple example of the paginator operating on an array. This shows the service paginating over an array of 12 items.
And in the twig view, it looks like this:
You can override the "items per page" and "pages in range" options at runtime by passing values to the paginator like this:
Please note that this is a very simple example, some advanced use-cases and interfaces are coming up (see below).
Doctrine Example
I've expanded the example above to use Doctrine instead of a static array of items:
And in the twig view, it looks like this:
Configuration
You can configure the Simple Pager Bundle from app/config/config.yml
with the following optional parameters:
Twig Function
I've provided a handy twig function to render the built in pagination template. The default template
can be configured in your app/config/config.yml
or simply overridden as an argument in the twig function.
The arguments passed to the twig function are as follows:
A brief description of each argument is:
- pagination: The
AshleyDawson\SimplePagination\Pagination
object returned byAshleyDawson\SimplePagination\Paginator::paginate()
- routeName: Route name to be passed to the navigation
{{ path() }}
function, defined in your routing config - pageParameterName: The name of the page number parameter in your request (optional)
- queryParameters: The array of query parameters to append to the path (optional)
- template: The template you'd like to use to override the default (optional)
An exhaustive twig view example is as follows:
A better example, with the accompanying item list:
Custom Service
If you'd like to define the paginator as a custom service, please use the following service container configuration.
In YAML:
or in XML:
Then use it in your controllers like this:
All versions of simple-pagination-bundle with dependencies
symfony/config Version ^3.4|^4.2|^5.0
symfony/dependency-injection Version ^3.4|^4.2|^5.0
symfony/http-kernel Version ^3.4|^4.2|^5.0
symfony/yaml Version ^3.4|^4.2|^5.0
twig/twig Version ^2.7|^3.0
ashleydawson/simple-pagination Version 1.0.*