PHPackages                             alirezax5/telegram-base - 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. alirezax5/telegram-base

ActiveProject[Framework](/categories/framework)

alirezax5/telegram-base
=======================

Telegram Bot Base Framework (project skeleton).

v2.3.0(1w ago)181MITPHP

Since Nov 7Pushed 1w agoCompare

[ Source](https://github.com/alirezax5/telegramBase)[ Packagist](https://packagist.org/packages/alirezax5/telegram-base)[ RSS](/packages/alirezax5-telegram-base/feed)WikiDiscussions main Synced 1w ago

READMEChangelog (10)Dependencies (50)Versions (23)Used By (0)

TelegramBase
============

[](#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
------------

[](#requirements)

- PHP 8.1+
- Composer
- Extensions: `json`, `mbstring`, `curl`
- Optional: `redis`, `memcached`, `amqp` (queue/cache backends)
- Optional: MySQL/MariaDB (database, Eloquent migrations)

Quick Start
-----------

[](#quick-start)

```
git clone https://github.com/alirezax5/telegramBase.git
cd telegramBase
cp .env.example .env
# Set BOT_TOKEN in .env
php bot.php
```

Bot Modes
---------

[](#bot-modes)

Set `BOT_MODE` in `.env`:

ModeDescription`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
----------------

[](#folder-structure)

```
├── App/                    # Framework core
│   ├── Attributes/         # PHP 8 attributes (ChatType)
│   ├── Bootstrap/          # Boot sequence (Config, Language, Button, Plugins)
│   ├── Bot/                # BotManager singleton
│   ├── Button/             # Keyboard helper + Keyboard builder
│   ├── Cache/              # CacheManager (array/file/redis/memcached/db)
│   ├── Cli/                # CLI Console + Maker (scaffolding)
│   ├── Config/             # AppConfig, RetryConfig, SessionConfig, SchedulerConfig
│   ├── Connection/         # Redis/Memcached/RabbitMQ connection configs
│   ├── Cron/               # CronManager + CronWorker
│   ├── Database/           # DatabaseManager, MigrationRunner, Migrations/
│   ├── Environment/        # EnvHandler + EnvironmentValidator
│   ├── Enum/               # CoreMode enum
│   ├── Language/           # i18n loader + helpers (__() )
│   ├── Logger/             # LogHandler + LoggerConfig
│   ├── Middleware/          # MiddlewareInterface, Pipeline + RateLimit/AuditLog/AdminGuard
│   ├── Plugin/             # PluginHandler, PluginInterface, ChatType attribute
│   ├── Queue/              # QueueManager, RetryQueue, RetryableException
│   ├── Scheduler/          # Scheduler, ScheduledTask, TaskLock
│   ├── Session/            # SessionManager, Session (cache-backed)
│   ├── Storage/            # OffsetStorage, CacheStore, QueueStore
│   └── Update/             # Fetcher, Processor, WebhookDispatcher
├── Plugin/                 # Bot plugins (your code)
├── Button/                 # Keyboard button definitions
├── Language/               # Translation files (PHP arrays)
├── Database/Migrations/    # Eloquent migration files
├── bin/                    # Entry scripts (tgbase CLI, scheduler)
├── AppData/                # Runtime data (queue, offsets, session, locks)
├── logs/                   # Log files
└── bot.php                 # Main entry point

```

CLI Commands
------------

[](#cli-commands)

```
php bin/tgbase  [arguments] [options]

# Scaffolding
make:plugin           Create a plugin class (options: --type=private|group|both)
make:middleware       Create a middleware class
make:session          Create a session helper
make:language         Create a language file (e.g. fa, en)
make:button           Create a button definition file
make:migration        Create a migration file (timestamped)

# Database
migrate                     Run pending migrations
migrate:rollback            Rollback the last batch
migrate:status              Show migration status

# Utility
list                        List all available commands
help                        Show help
```

Writing a Plugin
----------------

[](#writing-a-plugin)

Create a file in `Plugin/` — the framework auto-discovers it:

```
