2017 © Pedro Peláez
 

library paginator

Paginator library

image

anh/paginator

Paginator library

  • Monday, April 27, 2015
  • by hilobok
  • Repository
  • 2 Watchers
  • 2 Stars
  • 243 Installations
  • PHP
  • 2 Dependents
  • 1 Suggesters
  • 0 Forks
  • 0 Open issues
  • 5 Versions
  • 0 % Grown

The README.md

Paginator

Build Status Scrutinizer Code Quality SensioLabsInsight, (*1)

Installation

$ php composer.phar require 'anh/paginator:0.2.*'

Usage

Create paginator and call it's paginate() method with data, page number and number of elements per page. It will find appropriate adapter and return Page instance, filled with paginated data, it can be used in foreach directly. Also you can pass manually created adapter instead of data., (*2)

<?php

use Anh\Paginator\Paginator;

$query = /* ORM Query or QueryBuilder for fetching users */;

$paginator = new Paginator();
$users = $paginator->paginate($query, 1, 10);

foreach ($users as $user) {
    // do something with user
}

If you need to pass options to adapter, pass it to paginate() as fourth parameter. Note each adapter has own options., (*3)

<?php

use Anh\Paginator\Paginator;
use Anh\Paginator\Adapter\ArrayAdapter;

$data = array(/* elements */);

$paginator = new Paginator();
$elements = $paginator->paginate($data, 3, 20, array('preserveKeys' => true));

foreach ($elements as $key => $element) {
    // do something with element
}

You can create custom adapters and add them to AdapterResolver. All adapters must implement AdapterInterface interface., (*4)

<?php

use Anh\Paginator\Paginator;
use Anh\Paginator\AdapterResolver;

$adapterResolver = new AdapterResolver();
$adapterResolver->addAdapter('Some\Custom\Adapter1');
$adapterResolver->addAdapter('Some\Custom\Adapter2');

$paginator = new Paginator($adapterResolver);
$elements = $paginator->paginate($data, $pageNumber, $elementsPerPage);

foreach ($elements as $element) {
    // do something with element
}

Rendering

<?php

use Anh\Paginator\Paginator;
use Anh\Paginator\View\AdaptiveView;

$paginator = new Paginator();
$posts = $paginator->paginate(/* ... */);

$view = new AdaptiveView();
$view->setTemplates(array(/* templates */));
$view->setOptions(array(/* options */));

echo $view->render($posts, '/some/url/page-%page%', array(/* options */));

For complete list of templates and options see sources. Also you can use resource/pagination.css for paginator styling. It is based on pagination from foundation zurb., (*5)

Available adapters

  • EmptyDataAdapter
  • ArrayAdapter
  • DoctrineOrmAdapter

Versioning

Library uses semantic versioning., (*6)

License

MIT, (*7)

The Versions

27/04 2015

dev-master

9999999-dev

Paginator library

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

by Andrew Hilobok

paging pagination paginator pager

27/04 2015

v0.2.2

0.2.2.0

Paginator library

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

by Andrew Hilobok

paging pagination paginator pager

22/07 2014

v0.2.1

0.2.1.0

Paginator library

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

by Andrew Hilobok

paging pagination paginator pager

23/06 2014

v0.2.0

0.2.0.0

Paginator library

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

by Andrew Hilobok

paging pagination paginator pager

25/05 2014

v0.1.0

0.1.0.0

Paginator library

  Sources   Download

MIT

The Requires

  • php >=5.3.9

 

The Development Requires

by Andrew Hilobok

paging pagination paginator pager