Download the PHP package gruven/phpbotgram without Composer

On this page you can find all versions of the php package gruven/phpbotgram. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package phpbotgram

phpbotgram

PHP version PHPStan level

A modern PHP 8.5 port of the aiogram Telegram Bot framework.

phpbotgram keeps the layered architecture of the Python upstream — Bot, Session, Dispatcher, Router, filters, middlewares, FSM — but trades coroutines for amphp v3 fibers and uses native PHP 8.5 features (readonly classes, asymmetric visibility, property hooks, attributes, native enums) throughout.

Links

Requirements

Install

Quickstart — echo bot

Run with BOT_TOKEN=… php echo_bot.php. The full example (with extra documentation) lives at examples/echo_bot.php.

Examples

All examples are runnable and self-contained. Set BOT_TOKEN before launching (and BOT_TOKEN_2 for examples/multibot.php, which adds a second bot to the dispatcher when present).

Path Demonstrates
examples/echo_bot.php Long-polling echo bot
examples/echo_bot_webhook.php amphp/http-server webhook via SimpleRequestHandler + AmphpServer::run
examples/error_handling.php Global error observer that logs uncaught exceptions
examples/finite_state_machine.php Inline FSM (no scenes) for a multi-step form
examples/scene.php Scene-based FSM with SceneRegistry::add([Scene::class])
examples/quiz_scene.php Branching scene flow with conditional transitions
examples/own_filter.php Custom Filter subclass plumbed into $dispatcher->message->register
examples/specify_updates.php Restricting PollingOptions to a subset of update types
examples/context_addition_from_filter.php Filter returning kwargs consumed by the handler
examples/multibot.php One Dispatcher driving several Bot instances
examples/without_dispatcher.php Raw getUpdates loop bypassing the dispatcher
examples/stars_invoice.php Telegram Stars sendInvoice + PreCheckoutQuery flow
examples/inline_keyboard.php Inline keyboard builder + typed CallbackData + callback auto-answer
examples/deep_linking.php Deep-link /start payload generation and handling
examples/file_download.php Downloading user-sent documents/photos via Bot::download()

Core concepts

Bot and Session

Bot is a thin facade that builds typed API method DTOs (SendMessage, SendPhoto, …) and dispatches them through the BaseSession. The default session is AmphpSession, which builds an amphp/http-client instance via HttpClientBuilder, encodes form bodies, and surfaces Telegram error responses as typed exceptions (TelegramRetryAfter, TelegramServerException, TelegramBadRequestException, TelegramConflictException, TelegramForbiddenException, TelegramNetworkException, …). Polling-loop backoff on RetryAfter lives in the dispatcher, not the session itself.

Every typed API method returns its result directly (e.g. sendMessage(...) returns Types\Message). For deferred dispatch use the underlying method DTO directly via emit():

Dispatcher and Router

Dispatcher is a Router that owns the polling loop. Routers cascade — a parent router runs its own filters and middlewares before delegating to included child routers ($dispatcher->includeRouter($shopRouter)).

Filters and the F-DSL

Filter instances are invokable; they may return false, true, or a kwargs array merged into the handler arguments. Built-in filters cover commands (Command), magic field tests via the F constant (use const Gruven\PhpBotGram\F;), CallbackData::filter(), state predicates (StateFilter; a bare State instance is also directly usable as a filter), and combinators (Filter::all(), Filter::any(), Filter::invertOf()).

FSM scenes

Scenes are explicit (no metaclass auto-discovery): subclass Scene, declare state methods with #[OnMessage] / #[OnCallbackQuery], and register through SceneRegistry. Scene history, state, and storage isolation are all driven by FsmContext.

The framework injects ScenesManager $scenes as a handler kwarg when SceneRegistry has been attached to the dispatcher. While a scene state is active, router subtrees that contain that scene state are tried before broad parent catch-all handlers so free-text scene replies are not consumed by root fallbacks.

Webhook

Webhook\Server\AmphpServer::run() boots an amphp/http-server listener that routes inbound Update payloads through SimpleRequestHandler (single bot) or TokenBasedRequestHandler (multi-tenant). For full control over an existing amphp/http-server instance, use Webhook\Setup::register() to splice the bot lifecycle into your own startup/shutdown hooks.

amphp/http-server is a suggested dependency — install it explicitly before using webhook mode:

Testing

Equivalent make test / make stan / make lint / make coverage-gate / make docs-api targets exist for contributors who prefer the Makefile interface.

Tests against live external services are env-gated to keep CI offline by default:

Variable What it unlocks
PHPBOTGRAM_TEST_REDIS_DSN RedisStorage integration cases
PHPBOTGRAM_TEST_MONGO_DSN MongoStorage integration cases

Project structure

License

MIT. See LICENSE.

Upstream

Tracks aiogram 3.29.0. Behaviour divergences from upstream are documented inline at the call site (search for # Divergence: in the source) and in docs/superpowers/specs/.


All versions of phpbotgram with dependencies

PHP Build Version
Package Version
Requires php Version ^8.5
php-64bit Version ^8.5
ext-mbstring Version *
ext-json Version *
ext-sodium Version *
amphp/amp Version ^3
amphp/byte-stream Version ^2
amphp/http-client Version ^5
amphp/sync Version ^2
revolt/event-loop Version ^1
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package gruven/phpbotgram contains the following files

Loading the files please wait ...