2017 © Pedro Peláez
 

library php-pagination

PHP Pagination Class with 4 types: Simple Pagination, Google Pagination, Digg/PHPBB Pagination Style.

image

php-pagination/php-pagination

PHP Pagination Class with 4 types: Simple Pagination, Google Pagination, Digg/PHPBB Pagination Style.

  • Tuesday, June 27, 2017
  • by rafapaulino
  • Repository
  • 1 Watchers
  • 1 Stars
  • 202 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 1 Forks
  • 0 Open issues
  • 3 Versions
  • 494 % Grown

The README.md

PHP Pagination

PHP paging class with 4 different page types:, (*1)

  • Simple Pagination: Creates a simple pagination similar to Google. simple
  • PHPBB/Digg Pagination: Paging in the same style as the PHPBB CMS/Digg. In addition to the normal pages you have the markers with the last pages and home pages. phpbb
  • Jumping Pagination: Paging where the markers "jump" after a certain value, for example: Every 10 page markers are displayed from 1 to 10 - 11 to 20 - 21 to 30 and so on. jumping
  • Google Pagination: PHP paging is the same as that used by Google to display search results. google

See the examples folder for using the class easily., (*2)

Latest Stable Version Total Downloads Latest Unstable Version Monthly Downloads, (*3)

Donate, (*4)

Features

  • v2.0.1 Added method to get start for sql clauses.
  • v2.0.0 The methods were refactored, unit tests added, examples and design patters.

Important informations

  • You need PHP 7.0 or higher to use this class., (*5)

  • I used the strategy pattern to create different pagination types. I put the examples in the examples folder. This pagination returns only one PHP ArrayObject, so you create the layout part as you wish., (*6)

  • The pagination always returns the first page, last page, previous, next, an ArrayObject with total pages, 2 methods to advance or retreat a deternated number of pages and finally another ArrayObject with the markers following the paging style logic chosen., (*7)

  • This is a free project, feel free to use it in your projects, even if they are commercial. You can also contribute tips, new features and fixes., (*8)


Example of use

To use this class you must follow the code below. Do not forget to access the examples folder here in the repository with the usage examples for each page type. Also access rafaacademy.com for tips and tutorials on php and use of this class., (*9)

Install: composer require php-pagination/php-pagination, (*10)

<?php
require '../vendor/autoload.php';
use Pagination\Pagination;
use Pagination\StrategySimple;

if ( isset($_GET['page']) && is_numeric($_GET['page']) )
$page = $_GET['page'];
else 
$page = 1;

//use pagination class with results, per page and page
$pagination = new Pagination(1000, 10, $page);
//get first page
$pagination->getFirstPage();
//get last page
$pagination->getLastPage();
//get previous page
$pagination->getPreviousPage();
//get next page
$pagination->getNextPage();
//get all indexes
$all = $pagination->getAllIndexesOfPages();
$iteratorAll = $all->getIterator();
//get indexes in page stylized
$indexes = $pagination->getIndexes(new StrategySimple(15));
$iterator = $indexes->getIterator();

//get start for sql queries (optional - Note: This paging does not use a bank connection)
$pagination->getStartForSqlQueries();

To navigate between indexes you need to learn how to work with the ArrayInterator and ArrayObject of PHP., (*11)

The Versions

27/06 2017

dev-master

9999999-dev

PHP Pagination Class with 4 types: Simple Pagination, Google Pagination, Digg/PHPBB Pagination Style.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=7.0

 

The Development Requires

page paging pagination paginator

27/06 2017

2.0.1

2.0.1.0

PHP Pagination Class with 4 types: Simple Pagination, Google Pagination, Digg/PHPBB Pagination Style.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=7.0

 

The Development Requires

page paging pagination paginator

23/06 2017

2.0.0

2.0.0.0

PHP Pagination Class with 4 types: Simple Pagination, Google Pagination, Digg/PHPBB Pagination Style.

  Sources   Download

BSD-3-Clause

The Requires

  • php >=7.0

 

The Development Requires

page paging pagination paginator