thecipherdetective/phpeasykeyboard
Composer 安装命令:
composer require thecipherdetective/phpeasykeyboard
包简介
A simple library to create Telegram keyboards easy and fast.
README 文档
README
The easiest and fastest way to build Telegram keyboards in PHP 🚀
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
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 0
- 点击次数: 1
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: Unknown
- 更新时间: 2026-06-23