PHPackages                             m4n50n/telegram-bot-bundle - 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. [API Development](/categories/api)
4. /
5. m4n50n/telegram-bot-bundle

ActiveSymfony-bundle[API Development](/categories/api)

m4n50n/telegram-bot-bundle
==========================

This bundle provides a wrapper for using longman/telegram-bot inside Symfony.

0.1(2y ago)20601MITPHPPHP ^8.1

Since Feb 12Pushed 2y ago1 watchersCompare

[ Source](https://github.com/m4n50n/telegram_bot_bundle)[ Packagist](https://packagist.org/packages/m4n50n/telegram-bot-bundle)[ Docs](https://github.com/m4n50n/telegram_bot_bundle)[ RSS](/packages/m4n50n-telegram-bot-bundle/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (1)Dependencies (5)Versions (3)Used By (0)

PHP Telegram Bot Bundle
=======================

[](#php-telegram-bot-bundle)

[![Latest Stable Version](https://camo.githubusercontent.com/2b8db183219def77f23b6cd0fb230ed68ed85224537b6dbadde7f825df2decfc/68747470733a2f2f706f7365722e707567782e6f72672f6d346e35306e2f74656c656772616d2d626f742d62756e646c652f762f737461626c65)](https://packagist.org/packages/m4n50n/telegram-bot-bundle)[![License](https://camo.githubusercontent.com/62f05d80f9fc8af23beca4bb1a5dd42c70990980bc675ca0cc0d26ee4dd5bef6/68747470733a2f2f706f7365722e707567782e6f72672f6d346e35306e2f74656c656772616d2d626f742d62756e646c652f6c6963656e7365)](LICENSE.md)[![Total Downloads](https://camo.githubusercontent.com/851e8fb7fc8bdb2d9519b9825fbf74c5e473c2ca3855de5cbade82d8ff2a7429/68747470733a2f2f706f7365722e707567782e6f72672f6d346e35306e2f74656c656772616d2d626f742d62756e646c652f646f776e6c6f616473)](https://packagist.org/packages/m4n50n/telegram-bot-bundle)

This bundle provides a wrapper for using [PHP Telegram Bot](https://github.com/php-telegram-bot) inside Symfony. Additional documentation can be found in the official repository.

Installation
------------

[](#installation)

Open a command console, enter your project directory and execute the following command to download the latest stable version of this bundle:

```
symfony composer require m4n50n/telegram-bot-bundle

```

### Enable the Bundle

[](#enable-the-bundle)

Then, enable the bundle by adding it to the list of registered bundles in `config/bundles.php` file of your project:

```
// config/bundles.php

return [
    // ...
    M4n50n\TelegramBotBundle\TelegramBotBundle::class => ['all' => true],
];
```

Configure the Bundle
--------------------

[](#configure-the-bundle)

```
# config/packages/telegram_bot.yaml

telegram_bot:
  bots:
    first_bot:
      # Required #
      key: "%env(BOT_KEY)%"
      username: "%env(BOT_USERNAME)%"
      webhook:
        url: "%env(BOT_HOOK_URL)%"
        max_connections: "%env(BOT_MAX_CONNECTIONS)%"
      commands:
        paths:
          - "%env(BOT_COMMANDS_PATH)%"

      # Optional #
      admins:
        - 123456789 # Admin user id in Telegram
      mysql:
        enabled: true # false by default
        host: "%env(BOT_MYSQL_HOST)%"
        user: "%env(BOT_MYSQL_USER)%"
        password: "%env(BOT_MYSQL_ROOT_PASSWORD)%"
        database: "%env(BOT_MYSQL_DB)%"
      log:
        enabled: true # false by default
        debug: "%env(LOG_DEBUG_FILE_PATH)%"
        error: "%env(LOG_ERROR_FILE_PATH)%"
        update: "%env(LOG_UPDATE_FILE_PATH)%"
      paths:
        download: "%env(DOWNLOADS_PATH)%"
        upload: "%env(UPLOADS_PATH)%"
      limiter:
        enabled: true # false by default

    second_bot:
      # ...
```

If you want the configuration / environment files to be created automatically inside your `/config` folder, you can include my private *Symfony Flex* recipes repository in your `composer.json` by adding the following configuration:

```
"extra": {
  "symfony": {
      "endpoint": [
          "https://api.github.com/repos/m4n50n/symfony_flex_recipes/contents/index.json",
          "flex://defaults"
      ]
  }
}
```

Usage
-----

[](#usage)

Whenever you need to get a bot instance, use dependency injection for your service. The bot configuration is automatically loaded by providing the bot name, which should match the key in the configuration yaml file. For example:

```
telegram_bot:
  bots:
    first_bot: # $botName
```

```
use M4n50n\TelegramBotBundle\Factory\TelegramBotFactory;

final class TelegramBotService
{
    public function __construct(private TelegramBotFactory $botFactory)
    {
    }

    public function initialize(string $botName)
    {
        // ...
        return $this->botFactory->get($botName);
    }
}
```

### Methods

[](#methods)

This wrapper defines the basic bot configuration methods.

- `webhookHandler()` Method that will receive and handle incoming updates via an outgoing webhook.
- `setWebhook()` to register the webhook with Telegram. The endpoint to be configured as a webhook must be on a server with HTTPS support.
- `unsetWebhook()` to unregister the webhook.

If you create controllers for these methods, you will only have to do:

```
namespace App\Controller;

// ...

final class PHPCodeTesterBotController extends AbstractController
{
  private readonly TelegramBot $bot;

  public function __construct(private TelegramBotService $telegramBotService)
  {
    $this->bot = $telegramBotService->initialize("bot_name");
  }

  #[Route('/endpoint', name: 'app_webhook_endpoint')]
  public function webhookEndpoint(): Response
  {
    // ...
    $webhookHandler = $this->bot->webhookHandler();
    // ... or
    $setWebhook = $this->bot->setWebhook();
    // ... or
    $unsetWebhook = $this->bot->unsetWebhook();
    // ...
  }
}
```

Contributing
------------

[](#contributing)

See [CONTRIBUTING](CONTRIBUTING.md) for more information.

Security
--------

[](#security)

See [SECURITY](SECURITY.md) for more information.

License
-------

[](#license)

Please see the [LICENSE](LICENSE) included in this repository for a full copy of the MIT license, which this project is licensed under.

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity18

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity41

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

820d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/b085bcc17051770622ddf729c283cc1144a1d18fec27c34d3bcc68eba630709a?d=identicon)[m4n50n](/maintainers/m4n50n)

---

Top Contributors

[![m4n50n](https://avatars.githubusercontent.com/u/92524023?v=4)](https://github.com/m4n50n "m4n50n (7 commits)")

---

Tags

apibotbot-apibundlephpphp-telegram-botsymfonytelegramtelegram-apitelegram-botwrapperapibundlewrapperbottelegram

### Embed Badge

![Health badge](/badges/m4n50n-telegram-bot-bundle/health.svg)

```
[![Health](https://phpackages.com/badges/m4n50n-telegram-bot-bundle/health.svg)](https://phpackages.com/packages/m4n50n-telegram-bot-bundle)
```

###  Alternatives

[sylius/sylius

E-Commerce platform for PHP, based on Symfony framework.

8.4k5.6M651](/packages/sylius-sylius)[stfalcon-studio/api-bundle

Base classes and helper services to build API application via Symfony.

1032.1k](/packages/stfalcon-studio-api-bundle)

PHPackages © 2026

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