laraxgram / laragram
LaraGram, an advanced framework for Telegram Bot development.
Requires
- php: ^8.3
- laraxgram/core: ^4.5
- laraxgram/probe: ^0.1
- laraxgram/tempora: ^1
- laraxgram/watchdog: ^1.3
Requires (Dev)
- fakerphp/faker: ^1.24
Suggests
None
Provides
None
Conflicts
None
Replaces
None
- 4.x-dev
- v4.4.1
- v4.4.0
- v4.3.1
- v4.3.0
- v4.2.0
- v4.1.1
- v4.1.0
- v4.0.4
- v4.0.3
- v4.0.2
- v4.0.1
- v4.0.0
- 3.x-dev
- v3.1.1
- 3.1.0
- v3.0.11
- v3.0.10
- v3.0.9
- v3.0.8
- v3.0.7
- v3.0.6
- v3.0.5
- v3.0.4
- v3.0.3
- v3.0.2
- v3.0.1
- v3.0.0
- 2.x-dev
- v2.5.0
- v2.4.3
- v2.4.2
- v2.4.1
- v2.4.0
- v2.3.2
- v2.3.1
- v2.3.0
- v2.2.0
- v2.1.0
- v2.0.2
- v2.0.1
- v2.0.0
- 1.10.x-dev
- v1.10.3
- v1.10.2
- v1.10.1
- v1.9.x-dev
- v1.8.x-dev
- v1.7.x-dev
- dev-master
This package is auto-updated.
Last update: 2026-11-10 20:01:50 UTC
README
The full-stack framework for Telegram bots β AI-ready
LaraGram is a PHP framework for building Telegram bots with an expressive, elegant syntax. Listen to updates the way you define routes, reply with templates and keyboards, guide users through conversations, and broadcast to every chat β and when your bot grows, add AI agents, MTProto userbots, Telegram Mini Apps, APIs and admin panels to the same codebase.
# listens/bot.php use LaraGram\Request\Request; use LaraGram\Support\Facades\Bot; Bot::onCommand('start', function (Request $request) { $request->sendMessage(chat()->id, 'Hello LaraGram!'); }); Bot::onText('say {text}', function (Request $request, string $text) { $request->sendMessage(chat()->id, $text); });
π Official Documentation
LaraGram ships with complete documentation covering every major feature of the framework.
π Documentation
β³οΈ Installation :
LaraGram 4 requires PHP 8.3 or later and Composer.
composer global require laraxgram/installer laragram new my-bot
The installer configures your bot token and webhook, and optionally a local Bot API server, MTProto, a Mini App starter kit (React, Vue or Svelte), API routes, LaraGram Brain, Surge and your database. Then start everything you need for local development with:
php laragram dev
β¨ What You Can Build
π€ Telegram Bots
Everything a bot needs, built in.
- π§ Listening system modeled on routing β commands, text patterns, callback queries, payments, chat members and every other update type, with middleware, controllers, validation and rate limiting
- π‘ Typed Bot API client generated from the Bot API itself β responses as objects, failures such as flood waits or blocked bots as typed exceptions
- β¨οΈ Keyboard builder for inline and reply keyboards
- π§© Temple8 templates with a Blade-like syntax, plus Telegram rich messages with tables, lists and checklists
- π¬ Conversations & Step Manager for multi-step flows that validate every answer
- π’ Broadcasting to all users, groups or channels β queued, paced against flood limits, filterable, schedulable and trackable
- π Multi-bot support, webhook or long polling, and an optional local Bot API server
use LaraGram\Keyboard\Make; use LaraGram\Request\Request; use LaraGram\Support\Facades\Bot; use LaraGram\Support\Facades\Keyboard; Bot::onCommand('menu', function (Request $request) { $keyboard = Keyboard::inlineKeyboardMarkup( Make::row( Make::callbackData('π Say hello', 'hello'), ) )->get(); $request->sendMessage(chat()->id, 'What would you like to do?', reply_markup: $keyboard); }); Bot::onCallbackQueryData('hello', function (Request $request) { $request->answerCallbackQuery(); $request->sendMessage(user()->id, 'Hello '.user()->first_name.'!'); });
use LaraGram\Conversation\AnswersBag; use LaraGram\Conversation\Questioner; use LaraGram\Request\Request; use LaraGram\Support\Facades\Bot; use LaraGram\Support\Facades\Conversation; Bot::onCommand('feedback', function () { Conversation::inline(function (Questioner $q) { $q->ask('What went wrong?')->name('issue'); $q->ask('How can we reach you?')->name('contact'); }) ->onComplete(function (Request $request, AnswersBag $answers) { $request->sendMessage(user()->id, 'Thanks for your feedback!'); }) ->start(); });
Broadcast::users()->sendMessage('We just shipped a new feature! π')->queue();
π§ AI-Ready
Build AI features into your bot β and let AI help you build it.
- AI SDK β agents with tools and structured output for OpenAI, Anthropic, Gemini and more. Answers stream into the chat, photos, documents and voice messages become input, and an agent may reply with a quiz, a poll, a keyboard or an invoice. Tool calls can be approved with inline buttons β over the Bot API and MTProto alike.
- MCP β expose your application to AI clients with your own tools, resources and prompts, plus ready-made Telegram tool sets for the Bot API and MTProto.
- Brain β gives your coding agent LaraGram's conventions, offline documentation search, and tools to run your bot locally (list listens, simulate updates, render templates) without a single call reaching Telegram.
// An AI assistant that answers every message, in one line Bot::agent(SupportAgent::class); Bot::onText('/draw {prompt}', fn (string $prompt) => Image::of($prompt)->generate()); Bot::onVoice(fn (Request $request) => Transcription::fromUpload($request->file())->generate());
π MTProto & Userbots
Go beyond the Bot API and act as a real Telegram client.
- Log in as a user (phone + 2FA or QR) or as a bot over MTProto
- Read full chat history, list every dialog, download files of any size
- Receive hundreds of update types: typing, read receipts, reactions, storiesβ¦
- Run many user and bot accounts in one process
- LaraGram API Server β your own Bot API server written in PHP on top of MTProto, a drop-in replacement for the official
telegram-bot-api
# listens/client.php use LaraGram\MTProto\Facades\Client; use LaraGram\MTProto\Foundation\ClientRequest; Client::onText('hello', function (ClientRequest $request) { $request->sendMessage(peer: $request->chatId(), message: 'hi π'); });
π± Telegram Mini Apps
Build Mini Apps with React, Vue or Svelte through Luna β no separate API to write.
- Init data validated on every request, the Telegram user available on the server and in the frontend
- Telegram theme, MainButton, back button and closing confirmation
- CloudStorage, biometrics, location, sensors, popups, sharing and payments
- Starter kits to scaffold a Mini App in minutes
# routes/web.php Route::middleware('telegram')->group(function () { Route::get('/', [ProfileController::class, 'show'])->name('profile'); Route::post('/profile', [ProfileController::class, 'update']); });
π APIs
- API routes, API resources and pagination
- Citadel β personal access tokens with abilities, a complete OAuth2 server, SPA sessions and Telegram Mini App authentication behind one guard
- An expressive HTTP client for calling other services
# routes/api.php Route::get('/user', function (Request $request) { return $request->user(); })->middleware('auth:citadel');
π₯οΈ Web Pages & Admin Panels
Build the website, dashboard or admin panel of your bot in the same project.
- Web routing, controllers, middleware, HTTP requests & responses
- Blade views and Luna SPAs (React, Vue, Svelte) with Vite asset bundling
- Sessions, CSRF protection, authentication and authorization (Gate & Policy)
- Pagination with Tailwind and Bootstrap views, and live Precognition validation
# routes/web.php Route::middleware('auth')->prefix('admin')->group(function () { Route::get('/users', fn () => Luna::render('Admin/Users', [ 'users' => User::latest()->paginate(20), ])); });
π§± Foundation
- π¦ Eloquent ORM for MySQL, MariaDB, PostgreSQL, SQLite & SQL Server (+ MongoDB)
- π Migrations, seeders & factories
- β±οΈ Queues, jobs, task scheduling & concurrency
- π§ Cache, Redis, events, file storage & image manipulation
- π Logging, validation & localization
- π Encryption & hashing
- π» Commander console & Probe REPL
π οΈ Ecosystem
- β‘ Surge β serve bot updates and web requests from memory (Swoole, Open Swoole, RoadRunner, FrankenPHP)
- π‘οΈ Sentinel β update debugger, metrics monitor & Redis queue supervisor in one web dashboard
- π Watchdog β real-time logs in your terminal and in Telegram