PHPackages                             mehrdadkhoddami/php-telegram-bot-inline-keyboard-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. [Utility &amp; Helpers](/categories/utility)
4. /
5. mehrdadkhoddami/php-telegram-bot-inline-keyboard-pagination

ActiveLibrary[Utility &amp; Helpers](/categories/utility)

mehrdadkhoddami/php-telegram-bot-inline-keyboard-pagination
===========================================================

Customized PHP Telegram Bot InlineKeyboard Pagination

1.0.1(8y ago)027[2 issues](https://github.com/mehrdadkhoddami/TelegramBot-InlineKeyboardPagination/issues)MITPHPPHP ^7.0

Since Oct 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/mehrdadkhoddami/TelegramBot-InlineKeyboardPagination)[ Packagist](https://packagist.org/packages/mehrdadkhoddami/php-telegram-bot-inline-keyboard-pagination)[ Docs](https://github.com/mehrdadkhoddami/TelegramBotInlineKeyboardPagination)[ RSS](/packages/mehrdadkhoddami-php-telegram-bot-inline-keyboard-pagination/feed)WikiDiscussions master Synced yesterday

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

[Telegram Bot Inline Keyboard Pagination](https://github.com/php-telegram-bot/inline-keyboard-pagination "PHP Telegram Bot Inline Keyboard Pagination on GitHub")
=================================================================================================================================================================

[](#telegram-bot-inline-keyboard-pagination)

[![Scrutinizer Code Quality](https://camo.githubusercontent.com/8751d179bf5a4ae07d308a5e6e85214f159705cba9423990a8ad61ce71e1e595/68747470733a2f2f696d672e736869656c64732e696f2f7363727574696e697a65722f672f7068702d74656c656772616d2d626f742f696e6c696e652d6b6579626f6172642d706167696e6174696f6e2e737667)](https://scrutinizer-ci.com/g/php-telegram-bot/inline-keyboard-pagination/?branch=master "Code quality on Scrutinizer")[![Codecov](https://camo.githubusercontent.com/fa7314541e1ca85a3b516090eeef807240e4f02403d572108a54968ff79e068f/68747470733a2f2f696d672e736869656c64732e696f2f636f6465636f762f632f6769746875622f7068702d74656c656772616d2d626f742f696e6c696e652d6b6579626f6172642d706167696e6174696f6e2e737667)](https://codecov.io/gh/php-telegram-bot/inline-keyboard-pagination "Code coverage on Codecov")[![Build Status](https://camo.githubusercontent.com/a6a4a2980a29edde0a1d94647a6c267fb21429ba669e1a77dab845f605e75114/68747470733a2f2f696d672e736869656c64732e696f2f7472617669732f7068702d74656c656772616d2d626f742f696e6c696e652d6b6579626f6172642d706167696e6174696f6e2e737667)](https://travis-ci.org/php-telegram-bot/inline-keyboard-pagination "Build status on Travis-CI")

[![Latest Stable Version](https://camo.githubusercontent.com/6c23d5b2a82cd97fbb307bc420c5cd0fce6dba2275f961dc0ca6f8c27fe66d46/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d74656c656772616d2d626f742f696e6c696e652d6b6579626f6172642d706167696e6174696f6e2e737667)](https://packagist.org/packages/mehrdadkhoddami/php-telegram-bot-inline-keyboard-pagination "Customized PHP Telegram Bot Inline Keyboard Pagination on Packagist")[![Total Downloads](https://camo.githubusercontent.com/7e93ac874902624594a0cc0308d7bfbf0eae771866366e7d73d1051d7db9991b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f7068702d74656c656772616d2d626f742f696e6c696e652d6b6579626f6172642d706167696e6174696f6e2e737667)](https://packagist.org/packages/mehrdadkhoddami/php-telegram-bot-inline-keyboard-pagination "Customized PHP Telegram Bot Inline Keyboard Pagination on Packagist")[![License](https://camo.githubusercontent.com/69f935a3d74fa587aaf5aa704015d2c28b78b79a8fcd95724ee5c4a63bfff8da/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f7068702d74656c656772616d2d626f742f696e6c696e652d6b6579626f6172642d706167696e6174696f6e2e737667)](https://github.com/php-telegram-bot/inline-keyboard-pagination/blob/master/LICENSE "PHP Telegram Bot Inline Keyboard Pagination license")

- [About](#about)
- [Installation](#installation)
    - [Composer](#composer)
- [Usage](#usage)
    - [Test Data](#test-data)
    - [How To Use](#how-to-use)
- [Code Quality](#code-quality)
- [License](#license)

About
-----

[](#about)

A package based on [Telegram Bot Inline Keyboard Pagination](https://github.com/php-telegram-bot/inline-keyboard-pagination "Telegram Bot Inline Keyboard Pagination")

Installation
------------

[](#installation)

### Composer

[](#composer)

```
composer require php-telegram-bot/inline-keyboard-pagination:^1.0.0
```

Usage
-----

[](#usage)

### Test Data

[](#test-data)

```
$items         = range(1, 100); // required.
$command       = 'testCommand'; // optional. Default: pagination
$selected_page = 10;            // optional. Default: 1
$labels        = [              // optional. Change button labels (showing defaults)
    'default'  => '%d',
    'first'    => '« %d',
    'previous' => '‹ %d',
    'current'  => '· %d ·',
    'next'     => '%d ›',
    'last'     => '%d »',
];

// optional. Change the callback_data format, adding placeholders for data (showing default)
$callback_data_format = 'command={COMMAND}&oldPage={OLD_PAGE}&newPage={NEW_PAGE}'
```

### How To Use

[](#how-to-use)

```
// Define inline keyboard pagination.
$ikp = new InlineKeyboardPagination($items, $command);
$ikp->setMaxButtons(7, true); // Second parameter set to always show 7 buttons if possible.
$ikp->setRangeOffset(1); //optional: if you change offsets of selected page, you can use this method. e.g if selected page is 6 and Range offset set as 1, you will have 5 & 7 in pagination
$ikp->setLabels($labels);

/*
 *optional: But recommended. if you want that max_page will set according to labels you defined,
 * please call this method. if you remove $label elements and then call this method, max_page will be defined according to labels
 */
$ikp->setMaxButtonsBasedOnLabels();
$ikp->setCallbackDataFormat($callback_data_format);

// Get pagination.
$pagination = $ikp->getPagination($selected_page);

// or, in 2 steps.
$ikp->setSelectedPage($selected_page);
$pagination = $ikp->getPagination();
```

Now, `$pagination['keyboard']` is basically a row that contains the pagination.

```
// Use it in your request.
if (!empty($pagination['keyboard'])) {
    //$pagination['keyboard'][0]['callback_data']; // command=testCommand&oldPage=10&newPage=1
    //$pagination['keyboard'][1]['callback_data']; // command=testCommand&oldPage=10&newPage=7

    ...
    $data['reply_markup' => [
        'inline_keyboard' => [
            $pagination['keyboard'],
        ],
    ];
    ...
}
```

To get the callback data, you can use the provided helper method (only works when using the default callback data format):

```
// e.g. Callback data.
$callback_data = 'command=testCommand&oldPage=10&newPage=1';

$params = InlineKeyboardPagination::getParametersFromCallbackData($callback_data);

//$params = [
//    'command' => 'testCommand',
//    'oldPage' => '10',
//    'newPage' => '1',
//];

// or, just use PHP directly if you like. (literally what the helper does!)
parse_str($callback_data, $params);
```

Code Quality
------------

[](#code-quality)

Run the PHPUnit tests via Composer script.

```
composer test
```

License
-------

[](#license)

The MIT License (MIT). Please see [License File](https://github.com/php-telegram-bot/inline-keyboard-pagination/blob/master/LICENSE "PHP Telegram Bot Inline Keyboard Pagination license") for more information.

Project based on [Telegram Bot Pagination](https://github.com/lartie/Telegram-Bot-Pagination "Telegram Bot Pagination by Lartie on GitHub") by [lartie](https://github.com/lartie "Lartie on GitHub").

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity7

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity59

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 ~0 days

Total

2

Last Release

3129d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/3062af15c3eda37906df357ff7eb1d98482e04e7172c3515b43ca2ae6c29a7bf?d=identicon)[mehrdadkhoddami](/maintainers/mehrdadkhoddami)

---

Top Contributors

[![mehrdadkhoddami](https://avatars.githubusercontent.com/u/13401112?v=4)](https://github.com/mehrdadkhoddami "mehrdadkhoddami (9 commits)")

---

Tags

paginationquerycallbackbottelegraminlinekeyboard

###  Code Quality

TestsPHPUnit

Code StylePHP\_CodeSniffer

### Embed Badge

![Health badge](/badges/mehrdadkhoddami-php-telegram-bot-inline-keyboard-pagination/health.svg)

```
[![Health](https://phpackages.com/badges/mehrdadkhoddami-php-telegram-bot-inline-keyboard-pagination/health.svg)](https://phpackages.com/packages/mehrdadkhoddami-php-telegram-bot-inline-keyboard-pagination)
```

###  Alternatives

[php-telegram-bot/inline-keyboard-pagination

PHP Telegram Bot InlineKeyboard Pagination

298.8k1](/packages/php-telegram-bot-inline-keyboard-pagination)[php-telegram-bot/telegram-bot-manager

PHP Telegram Bot Manager

22014.5k](/packages/php-telegram-bot-telegram-bot-manager)[onmotion/yii2-telegram

Support chat for site based on Telegram bot

526.3k](/packages/onmotion-yii2-telegram)

PHPackages © 2026

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