Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/gpslab/pagination-bundle
Pagination bundle
https://github.com/gpslab/pagination-bundle
pagination php symfony-bundle symfony-flex
Last synced: about 12 hours ago
JSON representation
Pagination bundle
- Host: GitHub
- URL: https://github.com/gpslab/pagination-bundle
- Owner: gpslab
- License: mit
- Created: 2017-03-30T11:20:59.000Z (over 7 years ago)
- Default Branch: master
- Last Pushed: 2020-03-19T18:08:51.000Z (almost 5 years ago)
- Last Synced: 2024-12-16T11:56:39.727Z (8 days ago)
- Topics: pagination, php, symfony-bundle, symfony-flex
- Language: PHP
- Size: 201 KB
- Stars: 11
- Watchers: 2
- Forks: 2
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
[![Latest Stable Version](https://img.shields.io/packagist/v/gpslab/pagination-bundle.svg?maxAge=3600&label=stable)](https://packagist.org/packages/gpslab/pagination-bundle)
[![PHP from Travis config](https://img.shields.io/travis/php-v/gpslab/pagination-bundle.svg?maxAge=3600)](https://packagist.org/packages/gpslab/pagination-bundle)
[![Build Status](https://img.shields.io/travis/gpslab/pagination-bundle.svg?maxAge=3600)](https://travis-ci.org/gpslab/pagination-bundle)
[![Coverage Status](https://img.shields.io/coveralls/gpslab/pagination-bundle.svg?maxAge=3600)](https://coveralls.io/github/gpslab/pagination-bundle?branch=master)
[![Scrutinizer Code Quality](https://img.shields.io/scrutinizer/g/gpslab/pagination-bundle.svg?maxAge=3600)](https://scrutinizer-ci.com/g/gpslab/pagination-bundle/?branch=master)
[![StyleCI](https://styleci.io/repos/86694387/shield?branch=master)](https://styleci.io/repos/86694387)
[![License](https://img.shields.io/packagist/l/gpslab/pagination-bundle.svg?maxAge=3600)](https://github.com/gpslab/pagination-bundle)# PaginationBundle
![Pagination page 1](docs/pagination_page_1.png)
![Pagination page 4](docs/pagination_page_5.png)
![Pagination page 9](docs/pagination_page_9.png)
## Installation
Pretty simple with [Composer](http://packagist.org), run:
```sh
composer req gpslab/pagination-bundle
```## Configuration
Default configuration
```yaml
gpslab_pagination:
# Page range used in pagination control
max_navigate: 5# Name of URL parameter for page number
parameter_name: 'page'# Sliding pagination controls template
template: 'GpsLabPaginationBundle::pagination.html.twig'
```## Simple usage
```php
use GpsLab\Bundle\PaginationBundle\Service\Configuration;class ArticleController extends Controller
{
private const ARTICLES_PER_PAGE = 30;public function index(ArticleRepository $rep, Configuration $pagination): Response
{
$pagination->setTotalPages(ceil($rep->getTotalPublished() / self::ARTICLES_PER_PAGE));// get articles chunk
$offset = ($pagination->getCurrentPage() - 1) * self::ARTICLES_PER_PAGE;
$articles = $rep->getPublished(self::ARTICLES_PER_PAGE, $offset);return $this->render('AcmeDemoBundle:Article:index.html.twig', [
'articles' => $articles,
'pagination' => $pagination
]);
}
}
```Display pagination in template:
```twig
{{- pagination_render(pagination) -}}
```
## Documentation
* [Base usage](docs/base_usage.md)
* [From QueryBuilder](docs/from_qb.md)
* [From HTTP request](docs/from_request.md)
* [From HTTP request and QueryBuilder](docs/from_request_and_qb.md)
* [Request parameter name](docs/parameter_name.md)
* [Navigation pages range](docs/page_range.md)
* [Custom view](docs/custom_view.md)## License
This bundle is under the [MIT license](http://opensource.org/licenses/MIT). See the complete license in the file: LICENSE