longman/telegram-bot
longman/telegram-bot is a mature PHP library for building Telegram bots with a clean object-oriented API. It supports commands, inline keyboards, conversations, admin tools, webhooks and long polling, with extensive docs and examples for rapid bot development. Suitable for simple scripts and large b...
Architecture fit
longman/telegram-bot is a framework-agnostic Telegram Bot API client plus an opinionated command-routing layer (command classes extending Longman\TelegramBot\Commands\Command, split into system/user/admin command namespaces). It is an application skeleton as much as a library, which fits well when the bot is the product and less well when Telegram is a side channel inside an existing Laravel app.app/ that owns the Telegram instance, config, and route — acceptable, but it becomes our code to maintain.Telegram:: setters, static command registry, static Request/Response helpers). That is fine for classic PHP-FPM request lifecycles, but it is a real consideration under Laravel Octane/Swoole and it makes container-based DI into command classes awkward. Expect to resolve dependencies via app() inside execute() or to override the command factory. The 0.83.1 fix for setCustomBotApiUri — configuration set after the Telegram object exists now takes effect — is a direct example of this fragility: ordering dependence in static state was a live bug, not a hypothetical.0.82.0-0.83.0.sql) — the shipped schema is versioned and needs upgrade scripts applied in order, which is another reason to keep it out of our critical path.Integration feasibility
Request::fromJson(), dispatch via Telegram::run(), return 200. A working echo bot is an afternoon.getUpdates) is supported but is a poor fit for Laravel request/response hosting; it implies a supervised long-running worker or an artisan daemon.irazasyed/telegram-bot-sdk is materially more Laravel-native if container DI, facades, and queued jobs are priorities.Technical risk
dependents: 0 on Packagist indicates almost nobody consumes it as a library — its audience runs it as a standalone app. That is a weak proxy for library-grade API stability and semver discipline, and the 0.83.1 changelog reflects application-level concerns (SQL migrations) more than library-level API guarantees.retry_after backoff are not "solved" by the package at the application level. Idempotency on update_id and fast-ack + async processing must be designed in.setCustomBotApiUri fix confirms that global configuration is only applied at specific points in the object lifecycle — a class of bug that is materially harder to reason about in a long-lived worker.Key questions
Telegram instance per token, lifecycle, secret storage)?Stack fit
TelegramServiceProvider, config/telegram.php (token, webhook secret, command paths, allowed chats), a TelegramClient wrapper, and an Http/Controllers/TelegramWebhookController excluded from CSRF.AppCommand that pulls collaborators via app()), and write one test proving it works before scaling the pattern.Telegram instance is constructed. The 0.83.1 fix makes late configuration work, but relying on construction-order semantics is a trap we should not design around.Migration path
BotHandler interface first (handleUpdate(array $payload): void) and implement it twice — once over the old SDK, once over this package. Route and controller stay stable; handlers are swappable.execute() into queued jobs so the migration does not also migrate latency problems.deleteWebhook (or repoint the route) plus a feature flag on the controller. Telegram retains updates for 24h, so a botched cutover is recoverable.Compatibility
json, mbstring, curl; PDO/MySQL only if the manager is used).Sequencing
TelegramClient wrapper, base command class, error handling contract.update_id, 429/retry_after backoff, structured logging with update_id/chat_id correlation, alerting on webhook 5xx rate.Maintenance
Support
.env committed to a deploy repo; token rotation should be a rehearsed procedure.Scaling
foreach in a command.Failure modes
update_id is deduplicated.Ramp-up
Request/Response helpers, and /command naming are conventional and well documented. The entity/validation layer (Longman\TelegramBot\Entities) and edge cases (callback queries, inline mode, media groups) take longer — roughly a week to fluency.How can I help you explore Laravel packages today?