Download the PHP package yabx/telegram without Composer
On this page you can find all versions of the php package yabx/telegram. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download yabx/telegram
More information about yabx/telegram
Files in yabx/telegram
Informations about the package telegram
yabx/telegram
PHP SDK for the Telegram Bot API. Typed request/response objects, Guzzle HTTP client, and coverage aligned with Bot API 10.2 (July 2026).
Requirements
- PHP
>= 8.1 - Extensions:
json,curl - Composer dependencies:
guzzlehttp/guzzle^7.9,psr/log^3.0
Installation
Features
- Strongly typed
Yabx\Telegram\Objects\*models for available types - One method per Bot API method on
Yabx\Telegram\BotApi, matching available methods request()for direct API calls when you need maximum flexibility- Optional PSR-3 logging and custom Guzzle / base URL for tests or proxies
- Webhook parsing from raw JSON or
php://input getUpdateslong polling support
Quick start
Client options
Send messages (text, parse mode, reply)
Inline keyboard
Reply keyboard (custom keyboard)
Photo from disk (multipart upload)
If the path exists on disk, the client opens the file and sends it as multipart automatically:
Webhooks
Register and inspect the webhook:
Handle an incoming POST body (typical PHP endpoint):
Then branch on the update payload:
Long polling (getUpdates)
Low-level request()
Useful for new API parameters before a dedicated method exists, or rare calls:
Objects with a toArray() method are normalized automatically. Upload methods on BotApi already set multipart where needed.
Last raw API response
After each call, the decoded JSON envelope (including ok, result, description, etc.) is available:
Error handling
Failed Bot API responses throw Yabx\Telegram\Exception with Telegram’s error_code as the exception code when present:
Project layout
| Path | Role |
|---|---|
src/BotApi.php |
Client: all Bot API methods + request() |
src/Objects/ |
Telegram types (Message, Update, keyboards, …) |
src/Enum/ |
Helpers such as ChatAction, etc. |
tests/ |
PHPUnit test suite and JSON fixtures |
Testing
Optional coverage report (requires the PCOV extension locally):
HTML report in build/coverage/:
If PCOV is not installed, composer test:coverage prints installation hints instead of a cryptic PHPUnit error. CI collects coverage with PCOV on PHP 8.3 (job coverage in .github/workflows/tests.yml).
Tests use PHPUnit 10.5+ (PHP 8.1) or 11+ (PHP 8.2+) with Guzzle MockHandler for HTTP integration tests. Fixtures live in tests/Fixtures/.
Coverage phases
| Phase | Scope | Status |
|---|---|---|
| 1 | Infrastructure, Utils, BotApi, core objects |
done |
| 2 | All RichText / RichBlock types, update variants |
done |
| 3 | Polymorphic dispatchers (ChatMember, MessageOrigin, …) |
done |
| 4 | Round-trip manifest (tests/Fixtures/roundtrip/) |
done — 331 leaf classes (~93%); dispatchers tested separately |
| 5 | Composite variant tests (ChatFullInfo, Message, ExternalReplyInfo) |
done |
| 6 | All Update webhook variants |
done — 22 fixtures |
| 7 | BotApi integration (request serialization, response parsing) |
done — 57 tests |
| 8 | Composite variants (Message quote/forward, ExternalReplyInfo media) |
done |
| 9 | API response snapshots (tests/Fixtures/api_responses/) |
done — 7 fixtures |
| 10 | Shared MocksBotApi trait, multipart uploads, forum topic variants |
done |
| 11 | Media send methods, payments, ChatFullInfo private, service messages |
done |
| 12 | Location/contact/video note, stars, migration/members, getUpdatefromRequest |
done |
| 13 | Paid media, batch delete/copy, ChatBoostSource dispatcher, chat service messages |
done |
| 14 | Chat actions, reactions, join requests, sticker set snapshot, chat event messages | done |
| 15 | Live location, menu button, custom emoji, invite link snapshot, Update round-trip |
done |
| 16 | Live photo, forum topics, games, restrict member, service message variants | done — 79 BotApi tests, 13 snapshots |
| 17 | Chat admin, forum/general topics, stickers, bot profile/commands, join-query | done — 113 BotApi tests, ~69% BotApi.php lines |
| 18 | Business, stories, gifts/stars, payments, verification, managed bot, downloadFile |
done — 127 BotApi tests, ~99% BotApi.php lines |
| 19 | Deep Message / ChatFullInfo / Update variants |
done — 42 message fixtures, Message ~67% lines |
| 20 | BotApi edge cases: multipart, downloadFile, logging, transport errors |
done — BotApiEdgeCasesTest |
| 21 | API snapshots: business, gifts, boosts, invoice, extended chat | done — 18 snapshots |
| 22 | Polymorphic dispatch + sendPoll / InputPollMedia contract |
done |
| 23 | PHPStan level 2, coverage threshold 57%, CI static analysis | done — composer phpstan |
| 24 | CHANGELOG.md, README examples for Bot API 10.2 features |
done |
InputPollMedia / InputPollOptionMedia are PHP interfaces; implementing classes (InputMediaPhoto, InputMediaLink, …) are covered in the round-trip manifest and via sendPoll contract tests.
Static analysis and coverage gate
Bot API 10.2 examples
Ephemeral messages
Rich message blocks
Bot API 10.1 examples
Business connection
Stories (managed business account)
Gifts and Stars
Rich messages
To add coverage for a new object, append an entry to the appropriate file under tests/Fixtures/roundtrip/ (merged by roundtrip.php):
License
MIT (see composer.json).
See also
All versions of telegram with dependencies
ext-json Version *
ext-curl Version *
guzzlehttp/guzzle Version ^7.9
psr/log Version ^3.0