laraxgram/laragram
Laragram is a Laravel package for building Telegram bots with a fluent, expressive API. It offers webhook support, command routing, middleware, inline keyboards, and conversation-style flows, making bot development feel native to Laravel and quick to integrate into existing apps.
LaraGram is a Laravel-native framework for building Telegram bots: you get config-driven bot setup, an update dispatcher, handler/command classes, and a runtime that can either poll Telegram or receive webhooks. v4.3.0 is the first release with a formal runtime-driver abstraction (native, Surge, RoadRunner, FrankenPHP) and a built-in image driver, so treat 4.3 as the baseline for new projects.
Minimal path:
composer require laraxgram/laragram — this meta-package is now a thin aggregator over the split components, so confirm which laraxgram/* sub-packages it pulled in (composer show | grep laraxgram).php artisan vendor:publish --tag=laragram-config (check config/laragram.php for the token, webhook, runner and image blocks).LARAGRAM_BOT_TOKEN= to .env. Do not commit it; per-environment tokens (dev bot vs prod bot).laragram route/handler file the package provides.php artisan laragram:poll or equivalent), webhook in production.Where to look first, in order: the published config file (it documents the runner + image driver options added in 4.3), the bot kernel/entry class, then the split component READMEs for the feature you actually need. Because components are now separate packages, the config file is the fastest map of what is bundled versus what you must install explicitly.
First use case: a /start command that replies with a text message, wired to a single handler class. Get that round-tripping over long polling before you touch webhooks or runtime drivers — it isolates token/permission problems from infrastructure problems.
Handler-per-command, not a switch statement. Put each command in its own class and let the dispatcher resolve it. Updating a command then means touching one file, and the handler becomes trivially unit-testable by constructing it with a fake update.
Keep the runtime swappable. Since 4.3, the runner is a config concern rather than an application concern: native (php-fpm/built-in server) for simple webhook deployments, frankenphp or roadrunner for persistent workers, surge if you are already on that stack. Write your handlers so they never assume a request lifecycle — no $_SERVER reads, no reliance on request() in a worker context. This is what makes moving from native to RoadRunner/FrankenPHP a config change instead of a rewrite.
Long polling in dev, webhook in prod. Local: polling loop, no public URL, no TLS. Production: webhook route registered with setWebhook, secret token header validated. Keep both paths behind the same handler layer so staging and prod behave identically.
Image work through the driver, not raw GD/Imagick calls. The 4.3 native image driver means image manipulation (resizing photos before sendPhoto, generating thumbnails, watermarking) goes through a configured driver. Set it explicitly in config rather than letting auto-detection decide — production boxes often have GD but not Imagick, and the difference is only visible at runtime.
Queue anything that touches the network. Handler execution happens inside Telegram's webhook timeout expectations. Sending N media messages inline will burn through it. Dispatch a job per outbound batch, and use the package's rate-limit awareness rather than sleep().
Test against a faked API client. Assert the outgoing payload (method name + params) rather than hitting Telegram. Keep a small set of recorded update fixtures (message, callback query, edited message, channel post) and feed them to the dispatcher directly.
Multi-bot setups. If you run several bots, scope config per bot and avoid global singletons holding a token; the meta-package split in 4.3 makes it easier to instantiate independent bot instances from the sub-packages.
laraxgram/* packages. Symptoms after upgrading: classes suddenly missing, Class not found on handlers, or two versions of a component installed. Fix with composer update "laraxgram/*" --with-dependencies and check composer show for version drift between the meta-package and sub-packages. Pin exact versions in CI.composer.json after upgrading — a bumped PHP or framework constraint is the usual cause of "works locally, fails in CI". Run composer why-not laraxgram/laragram 4.3.0 if the update refuses to install.getWebhookInfo / deleteWebhook before polling. The reverse mistake — running the webhook route without the secret token check — is a security issue, not just a bug.retry_after. Honour it; the package can retry, but retries without backoff will get you temporarily restricted. Watch for per-chat rate limits when broadcasting.getFile downloads (20 MB at time of writing) — check size before attempting, and stream large files rather than buffering them in memory, especially on single-worker native runtimes.memory_limit.config:cache, confirm the webhook or poll command you use still exists under the same name, then smoke-test one message, one photo, one callback query.How can I help you explore Laravel packages today?