hybridgram / tgbot-laravel
Super fast package for Laravel to build Telegram bots powered by Go
0.2.0
2026-02-16 11:41 UTC
Requires
- php: ^8.4
- ext-pcntl: *
- laravel/prompts: ^0.3.7
- laravel/serializable-closure: ^2.0
- nyholm/psr7: ^1.8
- php-http/multipart-stream-builder: ^1.4
- phptg/bot-api: 0.14.1
- symfony/console: ^6.0|^7.0
- symfony/process: ^6.4|^7.0
Requires (Dev)
- larastan/larastan: ^3.0
- laravel/framework: ^11.0
- laravel/pint: ^1.25
- marcocesarato/php-conventional-changelog: ^1.17
- orchestra/testbench: ^9.0
- pestphp/pest: ^4.1
- phpstan/phpstan: ^2.1
This package is not auto-updated.
Last update: 2026-03-02 12:02:22 UTC
README
Laravel toolkit for fast Telegram bots creation with Go-powered webhook updating.
Quick start
composer require hybridgram/tgbot-laravel
php artisan vendor:publish --provider="HybridGram\Providers\TelegramServiceProvider"
Set BOT_TOKEN (and optional BOT_ID, BOT_NAME) in .env. Routing defaults to routes/telegram.php.
Minimal working example
routes/telegram.php
<?php use HybridGram\Facades\TelegramRouter; use HybridGram\Core\Routing\RouteData\TextMessageData; use HybridGram\Core\Routing\RouteData\PollData; use HybridGram\Telegram\Poll\PollType; use HybridGram\Telegram\TelegramBotApi; TelegramRouter::group(['for_bot' => 'main'], function (\HybridGram\Core\Routing\TelegramRouteBuilder $builder) { $builder->onTextMessage(function (TextMessageData $message) { $api = app(TelegramBotApi::class); $api->sendMessage($message->getChatId(), "Echo: {$message->text}"); }); // you can use any of route // $builder->onPoll(function (PollData $poll) { // $api = app(TelegramBotApi::class); // $api->sendMessage( // $poll->getChatId(), // "Poll received ({$poll->poll->type}) with " . count($poll->poll->options) . " options" // ); // }, pollType: PollType::REGULAR); });
Run polling in dev:
php artisan hybridgram:polling --hot-reload
Go module (go-proxy) and async updates for production
The bundled ./vendor/bin/tgook script downloads the go-proxy binary (from hybridgram/go-proxy) and runs it with your .env to stream updates via a high-performance Go worker. Use it when you need long-lived, asynchronous update handling without blocking PHP:
# install & run go-proxy with your .env
php ./vendor/bin/tgook
Key features
- Typed router covering Telegram updates (
onMessage,onPoll, callbacks, media, etc.). - Hot-reload polling for fast local development.
- Queue-aware outbound sending with rate limiting and HIGH/LOW priorities.
- Artisan helpers: set/delete webhook, list routes, configure bot settings.
Docs
- Supported update handlers:
telegram-update-types.md
