PHPackages                             uzdevid/yii2-telegrambot - 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. uzdevid/yii2-telegrambot

ActiveYii2-extension

uzdevid/yii2-telegrambot
========================

Extension for working with Telegram bot on PHP framework Yii2

127PHP

Since Jul 12Pushed 3y agoCompare

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

READMEChangelogDependenciesVersions (1)Used By (0)

Telegram Bot
============

[](#telegram-bot)

Telegram bot yaratish uchun qulaylashtirilgan kengaytma

O'rnatish
---------

[](#ornatish)

Kengaytmani [composer](http://getcomposer.org/download/) orqali o'rnatishingiz mumkin.

```
composer require uzdevid/yii2-telegrambot "dev-main"

```

Foydalanish
-----------

[](#foydalanish)

Konfiguratsiya parametrlarini kiritish.
---------------------------------------

[](#konfiguratsiya-parametrlarini-kiritish)

```
$config = [
    'token' => '',
    'parse_mode' => 'markdown',
    'webhook_url' => ''
];
```

Agar habarlarni faqat bitta chat-ga yuborqmoqchi bo'lsangiz ushbu massivga **chat\_id** ni ham qo'shishingiz mumkin.

Bot class-ini yaratish.
-----------------------

[](#bot-class-ini-yaratish)

```
$bot = new TelegramBot($config);
```

Chat-ga oddiy habar yuborish.
-----------------------------

[](#chat-ga-oddiy-habar-yuborish)

```
$bot->send(['chat_id' => 1234567, 'text' => 'Hello world']);
```

Agar **chat\_id** konfiguratsiyada ko'rsatilgan bo'lsa va yuborish uchun faqat matn berilsa quyidagi usuldan foydalanishingiz mumkin

```
$bot->send(['Hello world']);
```

Habarni o'zgartirish
--------------------

[](#habarni-ozgartirish)

```
$bot->edit(['message_id' => 1020, 'text' => "Yangi matn"]);
```

Tugmalar yaratish
-----------------

[](#tugmalar-yaratish)

Tugmalar yaratish

```
$bot->createKeyboard([
    [['text' => "Button 1"]],
    [['text' => "Button 2"]]
]);
$bot->send(['chat_id' => 1234567, 'text' => 'Mesage with url buttons']);
```

Habar ostida (inline) tugmalar yaratish

```
$bot->createInlineKeyboard([
    [['text' => "Button 1", 'url' => "https://google.com"]],
    [['text' => "Button 2", 'url' => "https://devid.uz"]]
]);
$bot->send(['chat_id' => 1234567, 'text' => 'Mesage with url buttons']);
```

Callback tugmalar yaratish

```
$bot->createInlineKeyboard([
    [['text' => "Callback Button 1", 'callback_data' => json_encode(['command' => '/btn-1'])]]
]);
$bot->send(['chat_id' => 1234567, 'text' => 'Mesage with callback']);
```

callback\_data paramtriga **command**-dan tashqari qo'shimcha paramtrlar qo'shishingiz mumkin. Misol uchun: id

```
$bot->createInlineKeyboard([
    [[
        'text' => "Callback Button 1",
        'callback_data' => json_encode(['command' => '/btn-1', 'id' => 100])
    ]]
]);
$bot->send(['chat_id' => 1234567, 'text' => 'Mesage with callback button and id']);
```

Webhook o'rnatish va o'chirish
------------------------------

[](#webhook-ornatish-va-ochirish)

Webhook o'rnatishda va o'chirishda konfiguratsiyada webhook\_url ko'rsatilgan bo'lishi shart. Qolgan holatlarda shart emas.

Webhook o'rnatish

```
$bot->setWebHook();
```

Webhook o'chirish

```
$bot->deleteWebHook();
```

Bot foydalanuvchisidan kelgan so'rovlarni qabul qilish, va javob qaytarish.
---------------------------------------------------------------------------

[](#bot-foydalanuvchisidan-kelgan-sorovlarni-qabul-qilish-va-javob-qaytarish)

```
$bot->onMessage('/start', function ($bot) {
    $bot->send("Chat ID: {$bot->chat_id}");
});
```

Callback tugmasi orqali kelgan so'rovni qayta ishlash.

```
$bot->onCallBack('/btn-1', function ($bot, $callback_data){
    $bot->send("Siz /btn-1 tugmasini bosdingiz. Tugma id-si: " . $callback_data['id']);
});
```

Ko'rib turganingizdek bu ikkala metod ichida **send** orqali habar yuboryatganingizda **chat\_id** ko'rsatishingiz shart emas. Qaysi foydalanuvchidan so'rov kelsa, javob ham huddi shu foydalanuvchiga qaytadi.

###  Health Score

16

—

LowBetter than 5% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity9

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity25

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.

### Community

Maintainers

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

---

Top Contributors

[![DikoIbragimov](https://avatars.githubusercontent.com/u/167644693?v=4)](https://github.com/DikoIbragimov "DikoIbragimov (1 commits)")

### Embed Badge

![Health badge](/badges/uzdevid-yii2-telegrambot/health.svg)

```
[![Health](https://phpackages.com/badges/uzdevid-yii2-telegrambot/health.svg)](https://phpackages.com/packages/uzdevid-yii2-telegrambot)
```

PHPackages © 2026

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