Download the PHP package devrabie/php-telegram-bot-plus without Composer
On this page you can find all versions of the php package devrabie/php-telegram-bot-plus. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download devrabie/php-telegram-bot-plus
More information about devrabie/php-telegram-bot-plus
Files in devrabie/php-telegram-bot-plus
Package php-telegram-bot-plus
Short Description A community-driven and updated fork of the popular php-telegram-bot/core library, with support for the latest Telegram Bot API features.
License MIT
Homepage https://github.com/devrabie/php-telegram-bot-plus
Informations about the package php-telegram-bot-plus
php-telegram-bot-plus
A community-driven and updated fork of the popular php-telegram-bot/core library, with support for the latest Telegram Bot API features.
📖 Overview
php-telegram-bot-plus is an enhanced and actively maintained fork of the great longman/php-telegram-bot library. This project was created to continue its development after the original project stalled, ensuring full support for the latest Telegram Bot API features and providing ongoing bug fixes and improvements for the community.
Our goal is to be a drop-in replacement for existing users, while providing powerful new features for new developers.
✨ Why choose php-telegram-bot-plus?
- 🚀 Up-to-date: Full support for the latest versions of the Telegram Bot API.
- 🛠️ Actively Maintained: Bugs from the original version are actively being fixed.
- 🧩 New Features: Adding powerful new features that were not previously available.
- 🤝 Community-Driven: We welcome contributions from developers to make the library better for everyone.
- 🔒 Compatible: We maintain backward compatibility as much as possible to make upgrading easy.
📦 Installation
🚀 Using the Redis Helper
This library provides a simple helper to integrate a Redis client, allowing you to easily use Redis for your custom data persistence needs (e.g., storing user states, settings, caching). The library itself remains stateless.
1. Enable Redis
In your main bot file (e.g., hook.php or your script that handles updates):
2. Use Redis in Your Commands
You can access the shared Redis client instance from any command class using automatic dependency injection. Simply add a redis property to your command class and it will be automatically populated:
You can also access the Redis instance statically from anywhere in your project:
3. Prevent Duplicate Updates
Enabling Redis also activates the built-in duplicate update prevention mechanism. This is useful when the bot receives the same update multiple times due to timeouts or retries from Telegram.
When Redis is enabled:
- The library checks if the
update_idexists in Redis. - If it exists, the update is ignored, and a fake success response is returned to Telegram to stop retries.
- If it doesn't exist, the
update_idis stored in Redis with a retention time (TTL) of 60 seconds.
You can customize the retention time (in seconds):
⚙️ Advanced Configuration
Request Timeout
To prevent your server from hanging on slow Telegram API requests (e.g., cURL error 28), you can set a custom timeout for the HTTP client. The default timeout is 60 seconds.
🔐 Webhook Secret Token
For enhanced security, you can set a secret token when you set your webhook. Telegram will then send this token in the X-Telegram-Bot-Api-Secret-Token header with every update. This library can automatically validate this token for you.
1. Set the Webhook with a Secret Token
When setting your webhook, provide a secret_token:
2. Configure Your Bot to Verify the Token
In your webhook handler (e.g., hook.php), set the same secret token on your Telegram object. The library will then automatically check the header on incoming requests and throw an exception if the token is missing or invalid.
This ensures that only requests from Telegram with the correct secret token are processed by your bot.
🙏 Acknowledgments A huge thanks to the original developers of longman/php-telegram-bot for their incredible work that formed the foundation of this project.
All versions of php-telegram-bot-plus with dependencies
ext-pdo Version *
ext-curl Version *
ext-json Version *
ext-mbstring Version *
guzzlehttp/guzzle Version ^7.9
psr/log Version ^3.0