Download the PHP package alirezax5/telegram-base without Composer
On this page you can find all versions of the php package alirezax5/telegram-base. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download alirezax5/telegram-base
More information about alirezax5/telegram-base
Files in alirezax5/telegram-base
Package telegram-base
Short Description Telegram Bot Base Framework (project skeleton).
License MIT
Informations about the package telegram-base
TelegramBase
A modular PHP 8.1+ Telegram bot framework built on Illuminate components, with a plugin system, queue backends, session management, middleware pipeline, scheduler, migration runner, and CLI scaffolding.
Requirements
- PHP 8.1+
- Composer
- Extensions:
json,mbstring,curl - Optional:
redis,memcached,amqp(queue/cache backends) - Optional: MySQL/MariaDB (database, Eloquent migrations)
Quick Start
Bot Modes
Set BOT_MODE in .env:
| Mode | Description |
|---|---|
update_direct |
Long-polling, process inline (default) |
update_queue |
Long-polling, push to queue |
webhook_direct |
Webhook, process inline |
webhook_queue |
Webhook, push to queue |
cronjob_update |
Cron-task polling (single slot) |
cronjob_queue |
Cron-task queue processing (N slots) |
Folder Structure
CLI Commands
Writing a Plugin
Create a file in Plugin/ — the framework auto-discovers it:
$messageis the message object (not the full update) — use$message->text,$message->chat->id, etc.
Handler methods
| Method | Triggered when |
|---|---|
onMessage |
Any text or media message |
onCallback_query |
Inline button pressed |
onCommand |
Slash command (e.g. /start) |
before |
Runs before every update |
after |
Runs after every update |
Attributes
Session
Session state persists between messages, stored via the Cache driver:
Config (.env)
Keyboard Builder
Build inline or reply keyboards with a fluent API:
Middleware
Pipeline-based middleware, runs before plugins:
Built-in Middlewares
| Middleware | Purpose |
|---|---|
RateLimit |
Sliding-window rate limiter per user |
AuditLog |
Logs every incoming update |
AdminGuard |
Restricts to ADMINS_WHITELIST from .env |
Retry Queue
Automatic retry for failed API calls (429/5xx), with exponential backoff:
Config (.env)
Scheduler
Cron-based task scheduler. Each tick runs bin/scheduler.php (e.g. every minute via crontab):
Schedule tasks in bin/tasks.php:
Webhook Mode
Switch to BOT_MODE=webhook_direct or webhook_queue in .env:
webhook.php is the entry point — it validates IP + secret token, then dispatches.
Migration
Database schema management via Illuminate Schema builder:
Migration file example:
Config (.env)
Queue Backends
| Driver | Env Setting | Use Case |
|---|---|---|
| JSON | json |
Default, file-based, no dependencies |
| Redis | redis |
High throughput, requires redis extension |
| Memcached | memcached |
Distributed, requires memcached |
| RabbitMQ | rabbitmq |
Enterprise messaging, requires amqp |
Cache Drivers
| Driver | Env Setting | Notes |
|---|---|---|
| Array | array |
In-memory, per-process (default) |
| File | file |
Persistent, uses CACHE_PATH |
| Redis | redis |
Shared, high-performance |
| Memcached | memcached |
Distributed cache |
| Database | database |
MySQL/MariaDB table-backed |
Configuration
All configuration via .env. Key groups:
| Group | Keys |
|---|---|
| Bot | BOT_TOKEN, BOT_MODE, POLLING_*, WEBHOOK_* |
| Plugins | PLUGINS_DIR, PLUGIN_CACHE_ENABLED, PLUGINS_RELOAD_INTERVAL |
| Language | LANG_DRIVER, DEFAULT_LANG, LANG_DIR |
| Buttons | BUTTONS_DIR, BUTTONS_FILE, BUTTONS_CACHE_TTL |
| Queue | QUEUE_SAVE_TYPE, RETRY_QUEUE_DRIVER, RETRY_* |
| Cache | CACHE_DRIVER, CACHE_PREFIX, CACHE_PATH |
| Session | SESSION_TTL, SESSION_PREFIX |
| Scheduler | SCHEDULER_LOCK_TTL, SCHEDULER_LOCK_TABLE |
| Database | DATABASE_ENABLE, DB_* |
| Logging | LOG_ENABLED, LOG_LEVEL, LOG_DIR |
See .env.example for full list with defaults.
Illuminate Components
This framework reuses (not forks) these Laravel/Illuminate packages:
| Package | Used for |
|---|---|
illuminate/cache |
Session, plugin cache, language cache, queue locks |
illuminate/database |
Eloquent ORM, Schema builder, migrations |
illuminate/pipeline |
Middleware pipeline |
illuminate/filesystem |
File-based cache, filesystem utilities |
illuminate/support |
Helpers, collections, Carbon, higher-order helpers |
illuminate/contracts |
Interfaces (Cache, Queue, Connection) |
illuminate/redis |
Redis cache/queue driver |
illuminate/events |
Event dispatcher (optional) |
illuminate/bus |
Task dispatch (optional) |
License
MIT
All versions of telegram-base with dependencies
vlucas/phpdotenv Version ^5.6
monolog/monolog Version ^3.9
illuminate/database Version ^10.0
php-amqplib/php-amqplib Version ^2.8
symfony/filesystem Version ^7.3
illuminate/cache Version ^10.49
illuminate/filesystem Version ^10.49
illuminate/events Version ^10.49
predis/predis Version ^3.4
illuminate/redis Version ^10.49