PHPackages                             mostafabaghi/telegram-bot - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [API Development](/categories/api)
4. /
5. mostafabaghi/telegram-bot

ActiveLibrary[API Development](/categories/api)

mostafabaghi/telegram-bot
=========================

A full-featured PHP class for interacting with Telegram Bot API

v1.0.0(9mo ago)12MITPHPPHP &gt;=7.4

Since Jul 24Pushed 9mo agoCompare

[ Source](https://github.com/mostafabaghi/telegram-bot)[ Packagist](https://packagist.org/packages/mostafabaghi/telegram-bot)[ RSS](/packages/mostafabaghi-telegram-bot/feed)WikiDiscussions main Synced 1mo ago

READMEChangelog (1)Dependencies (1)Versions (2)Used By (0)

Telegram Bot Plus
=================

[](#telegram-bot-plus)

[![Telegram Bot Api PHP](screenshot.png)](screenshot.png)

[![License: MIT](https://camo.githubusercontent.com/fdf2982b9f5d7489dcf44570e714e3a15fce6253e0cc6b5aa61a075aac2ff71b/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f4c6963656e73652d4d49542d79656c6c6f772e737667)](https://opensource.org/licenses/MIT)

A modern, fully featured PHP wrapper for the Telegram Bot API — built for developers who want full control and modern structure with PSR-4 compatibility.

GitHub: [github.com/mostafabaghi/telegram-bot](https://github.com/mostafabaghi/telegram-bot)

---

🚀 Features
----------

[](#-features)

- PSR-4 autoloading
- Full API support (sendMessage, sendMedia, Polls, Payments...)
- Debug logging
- Webhook handler system
- Event Dispatcher system (like Laravel listeners)
- IP validation for Telegram
- File uploads via URL, local, or stream (memory)

---

📦 Installation
--------------

[](#-installation)

```
composer require mostafabaghi/telegram-bot
```

> Or manually clone:

```
git clone https://github.com/mostafabaghi/telegram-bot.git
cd telegram-bot
composer install
```

---

🔧 Usage Example
---------------

[](#-usage-example)

### Basic usage:

[](#basic-usage)

```
use TelegramBot\TelegramBotPlus;

$bot = new TelegramBotPlus('YOUR_BOT_TOKEN');
$bot->sendMessage(123456789, 'Hello world!');
```

### Webhook handling:

[](#webhook-handling)

```
$bot->setWebhookHandler(function($update) use ($bot) {
    if (isset($update['message']['text'])) {
        $chatId = $update['message']['chat']['id'];
        $bot->sendMessage($chatId, "Received: " . $update['message']['text']);
    }
});

$bot->handleWebhook();
```

---

📚 Documentation
---------------

[](#-documentation)

### ✅ Core Methods

[](#-core-methods)

MethodDescription`sendMessage($chatId, $text, $options = [])`Send text message`sendPhoto($chatId, $photoPath, $caption = '')`Send image`sendMedia($type, $chatId, $media, $caption = '')`Send media (photo, video, document, ...)`sendMediaGroup($chatId, $mediaArray)`Send album (array of media)`sendPoll($chatId, $question, $options)`Create poll`sendInvoice(...)`Send payment invoice`answerCallbackQuery(...)`Answer inline button click### ⚙️ Webhook Management

[](#️-webhook-management)

```
$bot->setWebhook('https://yourdomain.com/webhook.php');
$bot->deleteWebhook();
$bot->getWebhookInfo();
```

### 💡 Event System

[](#-event-system)

```
$bot->on('message.text', function($message) use ($bot) {
    $bot->sendMessage($message['chat']['id'], 'Handled via event!');
});
```

### 🔐 IP Validation

[](#-ip-validation)

```
if (!$bot->isFromTelegram()) {
    http_response_code(403);
    exit('Access Denied');
}
```

---

🧪 Testing
---------

[](#-testing)

```
composer install
vendor/bin/phpunit
```

---

📜 License
---------

[](#-license)

MIT License © [mostafabaghi](https://github.com/mostafabaghi)

###  Health Score

27

—

LowBetter than 49% of packages

Maintenance59

Moderate activity, may be stable

Popularity4

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity35

Early-stage or recently created project

 Bus Factor1

Top contributor holds 100% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Unknown

Total

1

Last Release

288d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/d53409e07a776427157dadc01d5cb5d5999f11370594ee84a56deee8bcbc61e3?d=identicon)[mostafabaghi](/maintainers/mostafabaghi)

---

Top Contributors

[![mostafabaghi](https://avatars.githubusercontent.com/u/153000675?v=4)](https://github.com/mostafabaghi "mostafabaghi (11 commits)")

---

Tags

apibotphptelegramtelegram-bot-apitelegrambot

###  Code Quality

TestsPHPUnit

### Embed Badge

![Health badge](/badges/mostafabaghi-telegram-bot/health.svg)

```
[![Health](https://phpackages.com/badges/mostafabaghi-telegram-bot/health.svg)](https://phpackages.com/packages/mostafabaghi-telegram-bot)
```

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M475](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M270](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M186](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M451](/packages/google-gax)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
