PHPackages                             php-telegram-bot/fluent-keyboard - 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. [API Development](/categories/api)
4. /
5. php-telegram-bot/fluent-keyboard

ActiveLibrary[API Development](/categories/api)

php-telegram-bot/fluent-keyboard
================================

Fluent Keyboard builder for ReplyKeyboardMarkup and InlineKeyboardMarkup.

v1.2.0(4y ago)131.0k↓50%MITPHPPHP ^8.0

Since Mar 24Pushed 4y ago5 watchersCompare

[ Source](https://github.com/php-telegram-bot/fluent-keyboard)[ Packagist](https://packagist.org/packages/php-telegram-bot/fluent-keyboard)[ Fund](https://github.com/php-telegram-bot/core#donate)[ GitHub Sponsors](https://github.com/noplanman)[ RSS](/packages/php-telegram-bot-fluent-keyboard/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (3)Dependencies (1)Versions (5)Used By (0)

[![Version](https://camo.githubusercontent.com/f8d479d1def78a519d0ee30768c414597ed7d0677d485cbf470e4db71ef25d2b/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7068702d74656c656772616d2d626f742f666c75656e742d6b6579626f6172643f636f6c6f723d6f72616e6765266c6162656c3d56657273696f6e267374796c653d666f722d7468652d6261646765)](https://packagist.org/packages/php-telegram-bot/fluent-keyboard)[![PHP Version](https://camo.githubusercontent.com/caf49bcb7398b49f66ed7eb229e2e4b48af3984d53f4124831a1693a3557cf19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068702d74656c656772616d2d626f742f666c75656e742d6b6579626f6172643f7374796c653d666f722d7468652d6261646765)](https://camo.githubusercontent.com/caf49bcb7398b49f66ed7eb229e2e4b48af3984d53f4124831a1693a3557cf19/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f7068702d762f7068702d74656c656772616d2d626f742f666c75656e742d6b6579626f6172643f7374796c653d666f722d7468652d6261646765)[![Bot API](https://camo.githubusercontent.com/e47ce4a7c2d230b37ffb6bf6f697beb954fec9b383bde2ab219f664cc9cce764/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f426f742532304150492d352e37253230284a616e25323032303232292d2532333261396564363f7374796c653d666f722d7468652d6261646765)](https://core.telegram.org/bots/api#january-31-2022)[![Tests](https://camo.githubusercontent.com/2d80e0737363c5689111f36d2648a20c27d94c2173cf59a5f2d463a3e1d9c80d/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f776f726b666c6f772f7374617475732f7068702d74656c656772616d2d626f742f666c75656e742d6b6579626f6172642f54657374733f6c6162656c3d5465737473267374796c653d666f722d7468652d6261646765)](https://github.com/php-telegram-bot/fluent-keyboard/actions/workflows/tests.yaml)

 Table of Contents1. [Installation](#installation)
2. [Usage](#usage)
    1. [Defining a Keyboard](#defining-a-keyboard)
    2. [Defining Buttons](#defining-buttons)
    3. [Bind Buttons to a Keyboard](#bind-buttons-to-a-keyboard)
        1. [By Row](#by-row)
        2. [By Button](#by-button)
        3. [As Stack](#as-stack)
    4. [ForceReply and ReplyKeyboardRemove](#forcereply-and-replykeyboardremove)
    5. [KeyboardButtonPollType](#keyboardbuttonpolltype)

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

[](#installation)

Install the package using composer:

```
composer require php-telegram-bot/fluent-keyboard
```

([back to top](#top))

Usage
-----

[](#usage)

If you need to create a keyboard you can use the classes provided by this package as a drop-in replacement.

This is best explained with an example:

```
Request::sendMessage([
    'chat_id'      => 12345,
    'text'         => 'Keyboard Example',
    'reply_markup' => ReplyKeyboardMarkup::make()
        ->oneTimeKeyboard()
        ->button(KeyboardButton::make('Cancel'))
        ->button(KeyboardButton::make('OK')),
]);
```

A ReplyKeyboardMarkup is created by calling the static `make()` method on `ReplyKeyboardMarkup`. After that every field, like `one_time_keyboard`, can be chained by calling it in camelCase. Buttons can be added by calling the `button()` method. We have a detailed look on that later.

The classes and fields are named after the corresponding types and fields of the [Telegram Bot API](https://core.telegram.org/bots/api).

([back to top](#top))

### Defining a Keyboard

[](#defining-a-keyboard)

You can create a keyboard by calling the static `make()` method on its class.

After that you can chain methods to set additional fields that are available in the Bot API. This is done by calling the field name in camelCase. So instead of `input_field_placeholder`, you need to call `inputFieldPlaceholder()`.

```
ReplyKeyboardMarkup::make()
    ->inputFieldPlaceholder('Placeholder');
```

([back to top](#top))

### Defining Buttons

[](#defining-buttons)

The Buttons are created in the same way:

```
KeyboardButton::make()
    ->text('Send my Contact')
    ->requestContact();
```

As a shortcut, you can pass the mandatory `text` field as an argument to the static method `make()` like this:

```
KeyboardButton::make('Send my Location')
    ->requestLocation();
```

This is done the same way for `InlineKeyboardButton`:

```
InlineKeyboardButton::make('Login')
    ->loginUrl(['url' => 'https://example.com']);
```

To find out which fields are available have a look at the [Bot API documentation](https://core.telegram.org/bots/api).

([back to top](#top))

### Bind Buttons to a Keyboard

[](#bind-buttons-to-a-keyboard)

The keyboard does not work without any buttons, so you need to pass the buttons to the keyboard. There are a few ways to do this.

#### By Row

[](#by-row)

```
ReplyKeyboardMarkup::make()
    ->row([
        KeyboardButton::make('Cancel'),
        KeyboardButton::make('OK')
    ]);
```

If you need more than one row, call `row()` multiple times:

```
InlineKeyboardMarkup::make()
    ->row([
        InlineKeyboardButton::make('1')->callbackData('page-1'),
        InlineKeyboardButton::make('2')->callbackData('page-2'),
        InlineKeyboardButton::make('3')->callbackData('page-3')
    ])
    ->row([
        InlineKeyboardButton::make('prev')->callbackData('page-prev'),
        InlineKeyboardButton::make('next')->callbackData('page-next')
    ]);
```

[![InlineKeyboard with multiple rows](./docs/images/inlinekeyboard-multiple-rows.png)](./docs/images/inlinekeyboard-multiple-rows.png)

#### By Button

[](#by-button)

```
ReplyKeyboardMarkup::make()
    ->button(KeyboardButton::make('First Button'))
    ->button(KeyboardButton::make('Second Button'));
```

If you need more than one row, just call the row method without arguments, and continue calling `button()`:

```
InlineKeyboardMarkup::make()
    ->button(InlineKeyboardButton::make('A')->callbackData('answer-a'))
    ->button(InlineKeyboardButton::make('B')->callbackData('answer-b'))
    ->row()
    ->button(InlineKeyboardButton::make('C')->callbackData('answer-c'))
    ->button(InlineKeyboardButton::make('D')->callbackData('answer-d'));
```

[![InlineKeyboard with multiline buttons](./docs/images/inlinekeyboards-multiline-buttons.png)](./docs/images/inlinekeyboards-multiline-buttons.png)

It's up to you if you define your buttons inline like in these examples or if you'd like to generate a whole row beforehand and pass the variable to the `row()` method.

#### As Stack

[](#as-stack)

If you want to add a bunch of buttons that have each a row for themselves you can use the `stack()` method.

```
InlineKeyboardMarkup::make()
    ->stack([
        InlineKeyboardButton::make('Login')->loginUrl('https://example.com/login'),
        InlineKeyboardButton::make('Visit Homepage')->url('https://example.com')
    ]);
```

[![InlineKeyboard with stack](./docs/images/inlinekeyboard-stack.png)](./docs/images/inlinekeyboard-stack.png)

**You can mix and match the `row()`, `stack()` and `button()` methods as it fits your needs.**

([back to top](#top))

### ForceReply and ReplyKeyboardRemove

[](#forcereply-and-replykeyboardremove)

ForceReply and ReplyKeyboardRemove can be used the same way as a normal keyboard, but they do not receive any buttons:

```
$this->replyToUser('Thank you', [
    'reply_markup' => ReplyKeyboardRemove::make()->selective(),
]);
```

```
$data['reply_markup'] = ForceReply::make()->inputFieldPlaceholder('Please type something...');
```

([back to top](#top))

### KeyboardButtonPollType

[](#keyboardbuttonpolltype)

The `request_poll` field is a little special. You can specify which poll type the user can create by passing a `KeyboardButtonPollType` object.

```
KeyboardButton::make()->requestPoll(KeyboardButtonPollType::regular())
```

The `KeyboardButtonPollType` class has static methods for each possible type. But if there are new types in the future you don't have to wait until we release an update. You can either pass the array structure directly to the `requestPoll()` method or you pass the array structure to the constructor of `KeyboardButtonPollType`.

```
$pollButton = new KeyboardButtonPollType([
    'type' => 'quiz'
]);
```

###  Health Score

31

—

LowBetter than 68% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity23

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity57

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 96.7% 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 ~9 days

Total

4

Last Release

1482d ago

PHP version history (2 changes)v1.0.0PHP ^7.3|^8.0

v1.1.0PHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![TiiFuchs](https://avatars.githubusercontent.com/u/1958744?v=4)](https://github.com/TiiFuchs "TiiFuchs (29 commits)")[![noplanman](https://avatars.githubusercontent.com/u/9423417?v=4)](https://github.com/noplanman "noplanman (1 commits)")

---

Tags

apibuilderfluentbottelegramkeyboard

###  Code Quality

TestsPest

### Embed Badge

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

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

###  Alternatives

[borsaco/telegram-bot-api-bundle

A simple wrapper for telegram-bot-api.

5633.0k](/packages/borsaco-telegram-bot-api-bundle)[klev-o/telegram-bot-api

Simple and convenient object-oriented implementation Telegram bot API with php version ^7.4 support. You'll like it)

457.8k1](/packages/klev-o-telegram-bot-api)

PHPackages © 2026

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