PHPackages                             muxtorov98/php-telegram-framework - 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. [Framework](/categories/framework)
4. /
5. muxtorov98/php-telegram-framework

ActiveLibrary[Framework](/categories/framework)

muxtorov98/php-telegram-framework
=================================

⚡ Modular Telegram Bot Framework built with PHP 8.2+, supporting Handlers, Attributes, and Long Polling.

v1.0.0(7mo ago)101MITPHPPHP ^8.2

Since Nov 11Pushed 7mo agoCompare

[ Source](https://github.com/Muxtorov98/php-telegram-framework)[ Packagist](https://packagist.org/packages/muxtorov98/php-telegram-framework)[ RSS](/packages/muxtorov98-php-telegram-framework/feed)WikiDiscussions main Synced today

READMEChangelogDependencies (3)Versions (2)Used By (0)

🤖 Telegram Shop Bot (PHP / Laravel Capsule / Docker)
====================================================

[](#-telegram-shop-bot-php--laravel-capsule--docker)

Bu loyiha — Telegram orqali mahsulotlarni ko‘rish, savatga qo‘shish va buyurtma berish imkonini beruvchi **modulli Telegram Shop Bot** tizimi.

---

⚙️ Texnologiyalar
-----------------

[](#️-texnologiyalar)

- **PHP 8.2+**
- **Telegram Bot SDK** (`irazasyed/telegram-bot-sdk`)
- **Illuminate Database (Capsule ORM)** – Laravel ORM
- **PostgreSQL**
- **Docker &amp; Docker Compose**
- **Long Polling (Webhook’siz)**

---

📁 Loyihaning tuzilishi
----------------------

[](#-loyihaning-tuzilishi)

```
app/
 ├── Console/
 │   ├── Commands/
 │   │   ├── MigrateCommand.php
 │   │   ├── SetBotCommands.php
 │   │   └── ResetBotCommands.php
 │   └── ConsoleKernel.php
 ├── Core/
 │   ├── Bot.php
 │   ├── Router.php
 │   ├── Polling.php
 │   ├── FormFlowManager.php
 │   ├── Attributes/
 │   │   ├── Handler.php
 │   │   ├── FormStep.php
 │   │   └── Permission.php
 │   └── Helpers/
 │       ├── SessionHelper.php
 │       └── FileHelper.php
 ├── Handlers/
 │   ├── Users/
 │   │   ├── StartHandler.php
 │   │   ├── RegisterHandler.php
 │   │   └── AuthHandler.php
 │   └── Shop/
 │       ├── ProductViewHandler.php
 │       ├── CartHandler.php
 │       └── OrderHandler.php
 ├── Services/
 │   ├── LoggerService.php
 │   ├── PaginationHelper.php
 │   ├── ProductService.php
 │   ├── OrderService.php
 │   └── CartService.php
 └── Data/
     └── Config.php

```

---

🚀 Ishga tushirish
-----------------

[](#-ishga-tushirish)

### 1️⃣ Muhitni sozlash

[](#1️⃣-muhitni-sozlash)

`.env` fayl yarating (yoki `example.env` dan nusxa oling):

```
BOT_TOKEN=YOUR_TELEGRAM_BOT_TOKEN
DB_CONNECTION=pgsql
DB_HOST=db
DB_PORT=5432
DB_DATABASE=shop_bot
DB_USERNAME=postgres
DB_PASSWORD=postgres
CHAT_IDS=1234567
ADMIN_IDS=1234567,9999999
MANAGER_IDS=8888888,7777777
APP_DEBUG=true
```

---

### 2️⃣ Docker Compose bilan ishga tushirish

[](#2️⃣-docker-compose-bilan-ishga-tushirish)

```
docker compose up -d --build
```

---

### 3️⃣ Ma’lumotlar bazasi migratsiyalari

[](#3️⃣-malumotlar-bazasi-migratsiyalari)

```
docker compose exec telegram-bot php bin/console migrate
```

#### Migratsiya komandalar:

[](#migratsiya-komandalar)

KomandaTavsif`migrate`Barcha migratsiyalarni ishga tushiradi`migrate down`So‘nggi migratsiyalarni orqaga qaytaradi`migrate refresh`Hammasini o‘chirib, qayta yaratadi---

### 4️⃣ Botni ishga tushirish

[](#4️⃣-botni-ishga-tushirish)

```
docker compose exec telegram-bot php bin/console bot:run
```

Bu `Polling` orqali botni ishga tushiradi:

```
🤖 Bot started via long polling...

```

---

🧩 Komandalar (sidebar menyular)
-------------------------------

[](#-komandalar-sidebar-menyular)

Har bir rol uchun alohida menyu o‘rnatiladi:

### 👤 User menyu

[](#-user-menyu)

```
/start
/products
/cart
/my_orders
/help

```

### 👑 Admin menyu

[](#-admin-menyu)

```
/start
/add_product
/products
/cart
/orders
/notify_users
/help

```

### 🧑‍💼 Manager menyu

[](#‍-manager-menyu)

```
/start
/orders
/products
/help

```

Menyularni yangilash:

```
docker compose exec telegram-bot php bin/console set:commands
```

Eski menyularni tozalash:

```
docker compose exec telegram-bot php bin/console reset:commands
```

---

🧱 Asosiy komponentlar
---------------------

[](#-asosiy-komponentlar)

### 🔹 FormFlowManager

[](#-formflowmanager)

- Har bir `chat_id` uchun `step` va `answers` ma’lumotlarini sessiyada saqlaydi
- `context` bo‘yicha formani boshqaradi
- `reset()` orqali tozalaydi

### 🔹 Router

[](#-router)

- `#[Handler]` attributlari orqali avtomatik handlerlarni topadi
- `#[Permission]` orqali rolga asoslangan ruxsatni tekshiradi
- Fayl turlari (photo, document va boshqalar) uchun `file download` imkonini beradi
- `callback_query` bilan JSON yoki `prefix:data` formatlarini avtomatik ajratadi

### 🔹 Polling

[](#-polling)

- Long polling loop
- Har ishga tushganda avtomatik `SetBotCommands` chaqiradi
- Har bir `update` uchun `Bot::run()` orqali `Router`ni chaqiradi

---

💼 Shop modullari
----------------

[](#-shop-modullari)

### 🛍 `ProductViewHandler`

[](#-productviewhandler)

- `/products` orqali mahsulotlarni chiqaradi
- Inline tugmalar: `▶️ keyingi`, `◀️ oldingi`, `🛒 savatga qo‘shish`
- PaginationHelper orqali page boshqariladi

### 🛒 `CartHandler`

[](#-carthandler)

- `/cart` yoki `🛒 Savatim` orqali savatni ko‘rsatadi
- Inline tugmalar: `✅ Buyurtma berish`, `🗑 Tozalash`
- Session orqali cart saqlanadi (`$_SESSION['cart'][$chatId]`)

### 📦 `OrderHandler`

[](#-orderhandler)

- `✅ Buyurtma berish` tugmasi orqali savatdagi mahsulotlardan order yaratadi
- Orderlar `orders` jadvalida saqlanadi
- `/my_orders` komandasi orqali foydalanuvchi buyurtmalarini ko‘rishi mumkin

---

🧹 Avtomatik menyu yangilanishi
------------------------------

[](#-avtomatik-menyu-yangilanishi)

`Polling` ishga tushganda har safar:

```
(new \App\Console\Commands\SetBotCommands())->handle();
```

– shu sababli bot restart qilinganda menyular yangilanadi.

---

🛠 CLI komandalar
----------------

[](#-cli-komandalar)

KomandaTavsif`php bin/console migrate`Migratsiyalarni ishga tushirish`php bin/console set:commands`Telegram menyularni o‘rnatish`php bin/console reset:commands`Eski menyularni tozalash`php bin/console bot:run`Botni ishga tushirish (polling)---

📜 Loglar
--------

[](#-loglar)

Barcha loglar:

```
/storage/logs/bot.log

```

LoggerService quyidagi holatlarni rangli formatda yozadi:

- ✅ SUCCESS
- ⚠️ WARNING
- ❌ ERROR
- ℹ️ INFO

---

📦 Keyingi rejalashtirilgan modullar
-----------------------------------

[](#-keyingi-rejalashtirilgan-modullar)

- 🔐 JWT asosida autentifikatsiya
- 🧾 Excel / CSV buyurtma export
- 🧠 AI product recommendation
- 📊 Admin panel (Next.js + API)

---

👨‍💻 Muallif
-----------

[](#‍-muallif)

**Tulqin Muxtorov**
GitHub: [muxtorov98](https://github.com/muxtorov98)

---

> 🚀 *“Chat orqali sotuv — bu kelajakdagi e-commerce!”*

###  Health Score

32

—

LowBetter than 69% of packages

Maintenance62

Regular maintenance activity

Popularity3

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity48

Maturing project, gaining track record

 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

234d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/104984928?v=4)[Tulqin\_Muxtorov98](/maintainers/Muxtorov98)[@Muxtorov98](https://github.com/Muxtorov98)

---

Top Contributors

[![Muxtorov98](https://avatars.githubusercontent.com/u/104984928?v=4)](https://github.com/Muxtorov98 "Muxtorov98 (3 commits)")

---

Tags

phpframeworkbottelegrammodularlong-pollingtelegram-bot-sdk

### Embed Badge

![Health badge](/badges/muxtorov98-php-telegram-framework/health.svg)

```
[![Health](https://phpackages.com/badges/muxtorov98-php-telegram-framework/health.svg)](https://phpackages.com/packages/muxtorov98-php-telegram-framework)
```

###  Alternatives

[zemit-cms/core

Build Phalcon REST APIs faster with database-first scaffolding, model relationships, eager loading, identity, permissions, CLI, and WebSocket support.

148.5k1](/packages/zemit-cms-core)

PHPackages © 2026

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