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

AbandonedArchivedLibrary[API Development](/categories/api)

lex19/telegram
==============

telegram bot SDK

2.1.0(3y ago)2276[5 issues](https://github.com/les19/telegram/issues)[3 PRs](https://github.com/les19/telegram/pulls)MITPHPPHP ^8.0

Since Jan 5Pushed 2y ago1 watchersCompare

[ Source](https://github.com/les19/telegram)[ Packagist](https://packagist.org/packages/lex19/telegram)[ Docs](https://github.com/les19/telegram)[ GitHub Sponsors](https://github.com/les19)[ RSS](/packages/lex19-telegram/feed)WikiDiscussions master Synced 1mo ago

READMEChangelogDependencies (2)Versions (11)Used By (0)

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

[](#installation)

You can install the package via composer:

```
composer require lex19/telegram
```

Then you need publish config and create main Reception which will receive and process requests from the telegram hook

```
php artisan telegram:install
```

If you want to receive messages via a telegram hook, you need to create a route for this

```
// routes/web.php

use lex19\Telegram\Facades\Telegram;
use App\Telegram\Receptions\MainReception;

Route::any('hook', function(){
    return Telegram::hook(MainReception::class);
});
```

To install the hook (setWebHook), you just need to make a GET request for this route from the domain on which the bot will run.

Notice
------

[](#notice)

127.0.0.1 or localhost is not suitable. For local development, you can use the [ngrok](https://ngrok.com/) , and install a hook via a GET request to the address given to you:

Usage
-----

[](#usage)

If you want just send message by telegram\_id you can do this:

```
// AnyClass.php

use lex19\Telegram\Facades\Telegram;

Telegram::send([
    "chat_id" => 123456,
    "text" => "hello stranger!"
]);
```

To reply to messages from the bot, you need to create a command

```
php artisan telegram:command CommandName
```

This will create the command App\\Telegram\\Commands\\CommandName

```
// app/Telegram/Commands/CommandName.php

namespace App\Telegram\Commands;

use lex19\Telegram\Command;

class CommandName extends Command
{

  public function handle()
  {
    return $this->telegram->send('hello');
  }

}
```

And after that you can define this command in Reception in the commands property:

```
// app/Telegram/Receptions/MainReception.php

namespace App\Telegram\Receptions;

use lex19\Telegram\BaseReception;

class MainReception extends BaseReception
{

  protected $commands = [
    'say hello' => \App\Telegram\Commands\CommandName::class
  ];

}
```

You can bind commands to requests in different ways:

```
// app/Telegram/Receptions/MainReception.php

namespace App\Telegram\Receptions;

use lex19\Telegram\BaseReception;
use App\Telegram\Commands\CommandName;

class MainReception extends BaseReception
{

  protected $commands = [
    'say hello' => CommandName::class,
    'say hello myFunc' => [CommandName::class, 'myFunc'], // you use not just 'handle' method
  ];

    public function init()
    {
        $this->add('dynamic hello', [CommandName::class, 'dynamicHello']);
        $this->add([
            'dynamic hello 1' => [CommandName::class, 'dynamicHello1'],
            'dynamic hello 2' => [CommandName::class, 'dynamicHello2'],
        ]);
        $command = new CommandName;
        $this->add('dynamic hello 3', [$command, 'dynamicHello3']);
    }

}
```

If you want the following message, regardless of its content, to run a specific command, you can define it inside the current command:

```
// app/Telegram/Commands/CommandName.php

namespace App\Telegram\Commands;

use lex19\Telegram\Command;

class CommandName extends Command
{

  public function handle()
  {
    $this->setNext([CommandName::class, 'next']); // any next message will trigger this command

    return $this->telegram->send('hello');
  }

  public function next()
  {
    $text = $this->telegram->text;
    return $this->telegram->send("I don't care what you wrote there, but here it is: $text");
  }

}
```

###  Health Score

24

—

LowBetter than 32% of packages

Maintenance0

Infrequent updates — may be unmaintained

Popularity14

Limited adoption so far

Community10

Small or concentrated contributor base

Maturity61

Established project with proven stability

 Bus Factor1

Top contributor holds 50% 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

Every ~55 days

Total

5

Last Release

1375d ago

Major Versions

1.0.2 → 2.0.02022-04-10

### Community

Maintainers

![](https://www.gravatar.com/avatar/7d763fd3f4d3d2f0c15164213f0f7641358210795f9db76838ae07489bdcb281?d=identicon)[1ex19](/maintainers/1ex19)

---

Top Contributors

[![les19](https://avatars.githubusercontent.com/u/42060694?v=4)](https://github.com/les19 "les19 (20 commits)")[![dependabot[bot]](https://avatars.githubusercontent.com/in/29110?v=4)](https://github.com/dependabot[bot] "dependabot[bot] (10 commits)")[![github-actions[bot]](https://avatars.githubusercontent.com/in/15368?v=4)](https://github.com/github-actions[bot] "github-actions[bot] (10 commits)")

---

Tags

laraveltelegramtelegram bot1ex19

### Embed Badge

![Health badge](/badges/lex19-telegram/health.svg)

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

###  Alternatives

[irazasyed/telegram-bot-sdk

The Unofficial Telegram Bot API PHP SDK

3.3k4.5M84](/packages/irazasyed-telegram-bot-sdk)[telegram-bot-sdk/telegram-bot-sdk

The Telegram Bot API PHP SDK

32480.5k](/packages/telegram-bot-sdk-telegram-bot-sdk)[exileed/telegram-bot-api

The Telegram Bot API PHP

1514.1k](/packages/exileed-telegram-bot-api)

PHPackages © 2026

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