PHPackages                             motokraft/pagination - 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. motokraft/pagination

ActiveLibrary

motokraft/pagination
====================

Pagination by page using html-element

v1.0.2(3y ago)19MITPHPPHP &gt;=8.0

Since Jun 30Pushed 3y agoCompare

[ Source](https://github.com/motokraft/pagination)[ Packagist](https://packagist.org/packages/motokraft/pagination)[ Docs](https://github.com/motokraft/pagination)[ RSS](/packages/motokraft-pagination/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (2)Dependencies (3)Versions (3)Used By (0)

Пагинация по страницам с использованием html-element
====================================================

[](#пагинация-по-страницам-с-использованием-html-element)

[![Package version](https://camo.githubusercontent.com/f4776b225c89fcc68bcdd9c335e891aa5fe29e5e30f936398878fb7685dd3d01/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d6f746f6b726166742f706167696e6174696f6e)](https://camo.githubusercontent.com/f4776b225c89fcc68bcdd9c335e891aa5fe29e5e30f936398878fb7685dd3d01/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f762f72656c656173652f6d6f746f6b726166742f706167696e6174696f6e)[![Total Downloads](https://camo.githubusercontent.com/71feb9cfdeb555f81df8ad323e5a61f17cbc21909c9669af27cef71671f3be47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f746f6b726166742f706167696e6174696f6e)](https://camo.githubusercontent.com/71feb9cfdeb555f81df8ad323e5a61f17cbc21909c9669af27cef71671f3be47/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f6d6f746f6b726166742f706167696e6174696f6e)[![PHP Version](https://camo.githubusercontent.com/ba41893400c6af5a3999f576e0ac30cf20dd66675981bf533e9b6495fa99e4f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6f746f6b726166742f706167696e6174696f6e)](https://camo.githubusercontent.com/ba41893400c6af5a3999f576e0ac30cf20dd66675981bf533e9b6495fa99e4f0/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f6d6f746f6b726166742f706167696e6174696f6e)[![Repository Size](https://camo.githubusercontent.com/e80a170e5bff9935ab63090896d6e14f193e3ec06dc5b0b9de658c0c7d15492d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6d6f746f6b726166742f706167696e6174696f6e)](https://camo.githubusercontent.com/e80a170e5bff9935ab63090896d6e14f193e3ec06dc5b0b9de658c0c7d15492d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f7265706f2d73697a652f6d6f746f6b726166742f706167696e6174696f6e)[![License](https://camo.githubusercontent.com/03674e05864c3aa305e02b9ba97cc81fdac3b1b7afaa58f9b3efe80e21117d16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f746f6b726166742f706167696e6174696f6e)](https://camo.githubusercontent.com/03674e05864c3aa305e02b9ba97cc81fdac3b1b7afaa58f9b3efe80e21117d16/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f6d6f746f6b726166742f706167696e6174696f6e)

Установка
---------

[](#установка)

Библиотека устанавливается с помощью пакетного менеджера [**Composer**](https://getcomposer.org/)

Добавьте библиотеку в файл `composer.json` вашего проекта:

```
{
    "require": {
        "motokraft/pagination": "^1.0"
    }
}
```

или выполните команду в терминале

```
$ php composer require motokraft/pagination

```

Включите автозагрузчик Composer в код проекта:

```
require __DIR__ . '/vendor/autoload.php';
```

Привер класса вывода пагинации
------------------------------

[](#привер-класса-вывода-пагинации)

```
use \Motokraft\HtmlElement\HtmlElement;
use \Motokraft\Pagination\Renderer\BaseRenderer;
use \Motokraft\Pagination\Renderer\RendererInterface;
use \Motokraft\Uri\Uri;

class DemoPagination extends BaseRenderer implements RendererInterface
{
    function render(HtmlElement $element) : HtmlElement
    {
        $result = $element->appendCreateHtml('div', [
            'class' => 'category-pagination-inner'
        ]);

        // Вывод счетчика навигации
        $this->renderCounter($result);

        // Вывод контейнера навигация
        $this->renderPagination($result);

        return $result;
    }

    private function renderCounter(HtmlElement $element)
    {
        $padding = $this->getPagination();

        $div = $element->appendCreateHtml('div', [
            'class' => 'pagination-legend-inner'
        ]);

        $total = $padding->getTotal();
        $limitstart = $padding->getLimitStart();
        $limit = $padding->getLimit();
        $toResult = $total;

        if (($limitstart + $limit) < $total)
        {
            $toResult = $limitstart + $limit;
        }

        if ($total > 0)
        {
            $div->html(sprintf(
                'Showing %s to %s of %s entries',
                ($limitstart + 1), $toResult, $total
            ));
        }
        else
        {
            $div->html('No matching records found');
        }
    }

    private function renderPagination(HtmlElement $element)
    {
        $uri = clone Uri::getInstance();

        $nav = $element->appendCreateHtml('nav', [
            'class' => 'pagination-nav-inner'
        ]);

        // Кнопка 'В начало'
        $first = $this->_prepareFirstItem();
        $first = $first->render($nav, clone $uri);

        $first->addClass('nav-item-inner');
        $first->addAttrAria('label', 'First');

        // Кнопка 'Назад'
        $prev = $this->_preparePrevItem();
        $prev = $prev->render($nav, clone $uri);

        $prev->addClass('nav-item-inner');
        $prev->addAttrAria('label', 'Prev');

        foreach($this->_getPages() as $page)
        {
            // Нумерация страниц
            $page = $page->render($nav, clone $uri);
            $page->addClass('nav-item-inner');
        }

        // Кнопка 'Вперед'
        $next = $this->_prepareNextItem();
        $next = $next->render($nav, clone $uri);

        $next->addClass('nav-item-inner');
        $next->addAttrAria('label', 'Next');

        // Кнопка 'В конец'
        $last = $this->_prepareLasttItem();
        $last = $last->render($nav, clone $uri);

        $last->addClass('nav-item-inner');
        $last->addAttrAria('label', 'Last');
    }
}
```

Примеры инициализации
---------------------

[](#примеры-инициализации)

```
use \Motokraft\Pagination\Pagination;
use \Motokraft\HtmlElement\HtmlElement;

// Добавляем класс из примера выще
Pagination::addRenderer('demo', DemoPagination::class);

$div = new HtmlElement('div');

$pagination = new Pagination(367, 0, 10, 9);
$pagination->render($div, 'demo');

echo $div;
```

Полученный результат
--------------------

[](#полученный-результат)

```

            Showing 1 to 10 of 367 entries

                1

                2

                3

                4

                5

                6

                7

                8

                9

```

Лицензия
--------

[](#лицензия)

Эта библиотека находится под лицензией MIT License.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity6

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~1 days

Total

2

Last Release

1409d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/c50d7579f5a037c6f3f62a47cd1637771331b69e57389da513998a9ae934a0c2?d=identicon)[motokraft](/maintainers/motokraft)

---

Top Contributors

[![motokraft](https://avatars.githubusercontent.com/u/6596533?v=4)](https://github.com/motokraft "motokraft (3 commits)")

---

Tags

htmlhtml-elementhtml5paginationphp8phphtmlpaginationHTML5html-element

### Embed Badge

![Health badge](/badges/motokraft-pagination/health.svg)

```
[![Health](https://phpackages.com/badges/motokraft-pagination/health.svg)](https://phpackages.com/packages/motokraft-pagination)
```

###  Alternatives

[ressio/pharse

Fastest PHP HTML Parser

8478.4k](/packages/ressio-pharse)[daandesmedt/phpheadlesschrome

A PHP wrapper for using Google Chrome Headless mode. Convert URL or HTML to a PDF / screenshot. Easy to use and OOP interfaced.

92233.1k](/packages/daandesmedt-phpheadlesschrome)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
