thecipherdetective/phpeasykeyboard

There is no license information available for the latest version (dev-main) of this package.

A simple library to create Telegram keyboards easy and fast.

Maintainers

Package info

github.com/TheCipherDetective/phpEasyKeyboard

pkg:composer/thecipherdetective/phpeasykeyboard

Statistics

Installs: 0

Dependents: 0

Suggesters: 0

Stars: 0

Open Issues: 0

dev-main 2026-06-23 21:22 UTC

This package is auto-updated.

Last update: 2026-06-23 17:53:48 UTC


README

The easiest and fastest way to build Telegram keyboards in PHP 🚀

PHP License Composer

A lightweight and fluent PHP library for creating Inline Keyboards and Reply Keyboards for Telegram Bots.

About This Project

This library was my first real experience with Object-Oriented Programming (OOP) many years ago and found it when I was exploring my old codes. I originally designed and developed it as a learning project to better understand OOP concepts in PHP.

Even though I haven't actively maintained it for a while, I believe it can still be genuinely helpful for the community. Many existing Telegram wrappers make keyboard creation unnecessarily complicated, while phpEasyKeyboard focuses on maximum simplicity and a clean fluent interface.

✨ Features

  • Beautiful Fluent Interface (Method Chaining)
  • Support for all Telegram button types (Callback, URL, Web App, Request User, Copy, Login, etc.)
  • Automatic row & column management
  • Easy JSON conversion
  • PSR-4 compliant
  • Lightweight with zero dependencies

📦 Installation

composer require thecipherdetective/phpeasykeyboard

📌 Important Notes

  • Telegram limit: Maximum 100 buttons per keyboard
  • Check out example folder to see examples

🚀 Quick Start

Inline Keyboard

use TheCipherDetective\Telegram\Keyboards\InlineKeyboard;

$keyboard = new InlineKeyboard();

$keyboard
    ->createCallbackButton("👍 Like", "like_123")
    ->createUrlButton("🌐 Visit Website", "https://example.com")
    ->addRow() // Start new row
    ->createWebAppButton("🧩 Open Web App", ["url" => "https://example.com/webapp"])
    ->createCopyButton("📋 Copy Text", "Text to be copied");

echo $keyboard->getInlineKeyboardAsJson();

Reply Keyboard

use TheCipherDetective\Telegram\Keyboards\ReplyKeyboard;

$keyboard = new ReplyKeyboard(maxColumns: 3);

$keyboard
    ->createTextButton("📍 Send Location")
    ->createRequestContactButton("📞 Share Contact")
    ->createRequestLocationButton("📍 Share My Location")
    ->setResizeKeyboard(true)
    ->setOneTimeKeyboard(true);

echo $keyboard->getKeyboardAsJson();

📖 Documentation

InlineKeyboard Methods

Method Description
createCallbackButton($text, $callback_data) Callback button
createUrlButton($text, $url) URL button
createWebAppButton($text, $web_app) Web App button
createCopyButton($text, $copy_text) Copy text button
createLoginUrlButton(...) Login URL button
createSwitchInlineQueryButton(...) Switch inline query
getInlineKeyboard() Returns array
getInlineKeyboardAsJson() Returns JSON string

ReplyKeyboard Methods

Method Description
createTextButton($text) Regular text button
createRequestContactButton($text) Request contact
createRequestLocationButton($text) Request location
createRequestUsersButton(...) Request users
createRequestChatButton(...) Request chat
setResizeKeyboard(bool) Resize keyboard
setOneTimeKeyboard(bool) One-time keyboard
setIsPersistent(bool) Persistent keyboard
setPlaceholder(string) Input placeholder

⚙️ Configuration

// Custom grid size
new InlineKeyboard(maxColumns: 3, maxRows: 10);
new ReplyKeyboard(maxColumns: 4, maxRows: 8, is_persistent: true);

🤝 Contributing

Contributions, issues, and feature requests are very welcome!
Since this was originally a learning project, any help to improve code quality, add tests, fix typos, or enhance documentation is greatly appreciated.

📄 License

This project is licensed under the MIT License.

Made with ❤️ for the Telegram Bot developer community