muxtorov98/php-telegram-framework
Composer 安装命令:
composer require muxtorov98/php-telegram-framework
包简介
⚡ Modular Telegram Bot Framework built with PHP 8.2+, supporting Handlers, Attributes, and Long Polling.
README 文档
README
Bu loyiha — Telegram orqali mahsulotlarni ko‘rish, savatga qo‘shish va buyurtma berish imkonini beruvchi modulli Telegram Shop Bot tizimi.
⚙️ Texnologiyalar
- PHP 8.2+
- Telegram Bot SDK (
irazasyed/telegram-bot-sdk) - Illuminate Database (Capsule ORM) – Laravel ORM
- PostgreSQL
- Docker & Docker Compose
- Long Polling (Webhook’siz)
📁 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
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
docker compose up -d --build
3️⃣ Ma’lumotlar bazasi migratsiyalari
docker compose exec telegram-bot php bin/console migrate
Migratsiya komandalar:
| Komanda | Tavsif |
|---|---|
migrate |
Barcha migratsiyalarni ishga tushiradi |
migrate down |
So‘nggi migratsiyalarni orqaga qaytaradi |
migrate refresh |
Hammasini o‘chirib, qayta yaratadi |
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)
Har bir rol uchun alohida menyu o‘rnatiladi:
👤 User menyu
/start
/products
/cart
/my_orders
/help
👑 Admin menyu
/start
/add_product
/products
/cart
/orders
/notify_users
/help
🧑💼 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
🔹 FormFlowManager
- Har bir
chat_iduchunstepvaanswersma’lumotlarini sessiyada saqlaydi contextbo‘yicha formani boshqaradireset()orqali tozalaydi
🔹 Router
#[Handler]attributlari orqali avtomatik handlerlarni topadi#[Permission]orqali rolga asoslangan ruxsatni tekshiradi- Fayl turlari (photo, document va boshqalar) uchun
file downloadimkonini beradi callback_querybilan JSON yokiprefix:dataformatlarini avtomatik ajratadi
🔹 Polling
- Long polling loop
- Har ishga tushganda avtomatik
SetBotCommandschaqiradi - Har bir
updateuchunBot::run()orqaliRouterni chaqiradi
💼 Shop modullari
🛍 ProductViewHandler
/productsorqali mahsulotlarni chiqaradi- Inline tugmalar:
▶️ keyingi,◀️ oldingi,🛒 savatga qo‘shish - PaginationHelper orqali page boshqariladi
🛒 CartHandler
/cartyoki🛒 Savatimorqali savatni ko‘rsatadi- Inline tugmalar:
✅ Buyurtma berish,🗑 Tozalash - Session orqali cart saqlanadi (
$_SESSION['cart'][$chatId])
📦 OrderHandler
✅ Buyurtma berishtugmasi orqali savatdagi mahsulotlardan order yaratadi- Orderlar
ordersjadvalida saqlanadi /my_orderskomandasi orqali foydalanuvchi buyurtmalarini ko‘rishi mumkin
🧹 Avtomatik menyu yangilanishi
Polling ishga tushganda har safar:
(new \App\Console\Commands\SetBotCommands())->handle();
– shu sababli bot restart qilinganda menyular yangilanadi.
🛠 CLI komandalar
| Komanda | Tavsif |
|---|---|
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
Barcha loglar:
/storage/logs/bot.log
LoggerService quyidagi holatlarni rangli formatda yozadi:
- ✅ SUCCESS
- ⚠️ WARNING
- ❌ ERROR
- ℹ️ INFO
📦 Keyingi rejalashtirilgan modullar
- 🔐 JWT asosida autentifikatsiya
- 🧾 Excel / CSV buyurtma export
- 🧠 AI product recommendation
- 📊 Admin panel (Next.js + API)
👨💻 Muallif
Tulqin Muxtorov
GitHub: muxtorov98
🚀 “Chat orqali sotuv — bu kelajakdagi e-commerce!”
muxtorov98/php-telegram-framework 适用场景与选型建议
muxtorov98/php-telegram-framework 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 0 次下载、GitHub Stars 达 1, 最近一次更新时间为 2025 年 11 月 11 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「framework」 「php」 「bot」 「modular」 「long-polling」 「telegram」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 muxtorov98/php-telegram-framework 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 muxtorov98/php-telegram-framework 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 muxtorov98/php-telegram-framework 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
PHP Framework HLEB2 is the foundation of the web application. Provides ease of development and application performance.
Dialogflow php sdk
Laravel 5.6 Monolog custom telegram channel
Alfabank REST API integration
VK driver for botman
Telegram bot integration with laravel
统计信息
- 总下载量: 0
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 1
- 点击次数: 29
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2025-11-11