tueen / telegram
The Royal Telegram Bot SDK for Modern PHP โ declarative, stateful, and resilient.
Requires
- php: >=8.4.0
- guzzlehttp/guzzle: ^7.8
- psr/event-dispatcher: ^1.0
- psr/http-client: ^1.0
- psr/http-factory: ^1.0
- psr/http-message: ^1.0 || ^2.0
- psr/log: ^3.0
Requires (Dev)
- phpunit/phpunit: ^11.0
Suggests
- psr/container: To enable PSR-11 dependency injection in controllers and handlers
Provides
None
Conflicts
None
Replaces
None
This package is auto-updated.
Last update: 2026-11-05 01:53:52 UTC
README
Tueen Telegram ๐
The Royal Telegram Bot SDK for Modern PHP
Part of the Tueen ecosystem โ "The Queen of Telegram"
โก Highlights
- ๐ Complete Bot API Coverage โ Strictly-typed methods, models, and enums for all Telegram features.
- ๐ Modern PHP 8.4+ Architecture โ Built with property hooks, asymmetric visibility, and zero legacy baggage.
- ๐งญ Expressive Routing โ Commands, callback queries, regex matchers, and PHP 8 attribute controllers.
- โจ๏ธ Fluent Keyboards & Safe Formatting โ Intuitive Inline/Reply builders and entity-safe HTML/MarkdownV2 styling.
- ๐ฌ Conversational Flows & Navigation โ Multi-step state machines, hierarchical screen stacks, and zero-flicker UI transitions.
- ๐ Production Webhook & Polling โ Secret token validation and persistent worker support (FrankenPHP, Swoole, RoadRunner).
- ๐ Zero-Config App & Web Dashboard โ Instant bot launcher with a CLI toolkit and an embedded management dashboard.
- ๐ Resilient HTTP Pipeline โ Persistent connection pooling, automatic rate-limit backoff, and PSR-3 logging.
- ๐ก๏ธ Dual Error Modes โ Choose between traditional exceptions or typed error objects with universal status checks.
- ๐งช In-Memory Testing โ First-class testing fakes with expressive assertions and zero HTTP overhead.
๐ฆ Requirements & Installation
- PHP 8.4 or higher (fully compatible with PHP 8.5+)
- Composer 2.x
- Extensions:
json,curlor stream wrappers,mbstring
composer require tueen/telegram
๐ Quickstart
Build an interactive bot with command routing, inline buttons, and safe HTML formatting:
<?php declare(strict_types=1); use Tueen\Telegram\Telegram; use Tueen\Telegram\Types\User; use Tueen\Telegram\Types\Update; use Tueen\Telegram\Keyboards\InlineKeyboard; use Tueen\Telegram\Formatting\Text; require __DIR__ . '/vendor/autoload.php'; $bot = new Telegram('YOUR_BOT_TOKEN'); // Handle /start command with auto-wired User parameter $bot->onCommand('start', function (User $user, Telegram $bot) { $keyboard = InlineKeyboard::make() ->row() ->callback('โจ Explore', 'action:explore') ->url('๐ Documentation', 'https://tueen.github.io/telegram/') ->build(); $bot->reply( Text::html() ->bold("Welcome, {$user->firstName}! ๐")->line() ->plain("Ready to build modern Telegram bots with PHP 8.4+?"), replyMarkup: $keyboard ); }); // Handle callback query button tap $bot->onCallbackQuery('action:explore', function (Update $update, Telegram $bot) { $bot->answerCallbackQuery($update->callbackQuery->id); $bot->reply('Explore full guides and examples at https://tueen.github.io/telegram/'); }); // Start long-polling (or configure WebhookMode for production) $bot->usePollingMode(); $bot->run();
๐ก Looking for zero-config single-file bootstrapping and the embedded Web Dashboard? Check out the Zero-Config App & Web Dashboard Guide.
๐ Documentation
Complete guides, real-world examples, configuration options, and API catalogs are available in our official documentation:
๐ https://tueen.github.io/telegram/
For AI coding assistants (Cursor, Claude, ChatGPT), machine-readable context and offline skill packages are available at the AI & LLM Context Hub.
๐ License
tueen/telegram is open-sourced software licensed under the MIT License.