Download the PHP package php-telegram-bot/fluent-keyboard without Composer

On this page you can find all versions of the php package php-telegram-bot/fluent-keyboard. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package fluent-keyboard

Version PHP Version Bot API Tests

Table of Contents
  1. Installation
  2. Usage
    1. Defining a Keyboard
    2. Defining Buttons
    3. Bind Buttons to a Keyboard
      1. By Row
      2. By Button
      3. As Stack
    4. ForceReply and ReplyKeyboardRemove
    5. KeyboardButtonPollType

Installation

Install the package using composer:

(back to top)

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:

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.

(back to top)

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().

(back to top)

Defining Buttons

The Buttons are created in the same way:

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

This is done the same way for InlineKeyboardButton:

To find out which fields are available have a look at the Bot API documentation.

(back to top)

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

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

By Button

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

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

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

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

(back to top)

ForceReply and ReplyKeyboardRemove

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

(back to top)

KeyboardButtonPollType

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

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.


All versions of fluent-keyboard with dependencies

PHP Build Version
Package Version
Requires php Version ^8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package php-telegram-bot/fluent-keyboard contains the following files

Loading the files please wait ....