PHPackages                             lukasss93/telegrambot-php - 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. lukasss93/telegrambot-php

Abandoned → [nutgram/nutgram](/?search=nutgram%2Fnutgram)ArchivedProject[API Development](/categories/api)

lukasss93/telegrambot-php
=========================

Framework for Telegram Bot API

v1.14.1(4y ago)286617[1 PRs](https://github.com/Lukasss93/telegrambot-php/pulls)MITPHPPHP ^7.2|^8.0

Since Jan 24Pushed 3y ago1 watchersCompare

[ Source](https://github.com/Lukasss93/telegrambot-php)[ Packagist](https://packagist.org/packages/lukasss93/telegrambot-php)[ RSS](/packages/lukasss93-telegrambot-php/feed)WikiDiscussions master Synced 4w ago

READMEChangelog (10)Dependencies (1)Versions (46)Used By (0)

⚠️ This package is abandoned and no longer maintained.
Please use the [nutgram/nutgram](https://github.com/nutgram/nutgram) package instead.
--------------------------------------------------------------------------------------------------------------------------------------------

[](#️-this-package-is-abandoned-and-no-longer-maintainedplease-use-the-nutgramnutgram-package-instead)

---

TelegramBot-PHP
===============

[](#telegrambot-php)

[![API](https://camo.githubusercontent.com/04f128a1122e1ae2320c81efe9668df4d1282d476c2dfe7fa0163083f5705013/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f54656c656772616d253230426f742532304150492d352e332530392d2d2532304a756e652532303235253243253230323032312d626c75652e737667)](https://core.telegram.org/bots/api)[![PHP](https://camo.githubusercontent.com/990aa50be45969129fbabd33b67a75f2075e723f149d1adf4088bdd9e8b9e5e1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230372e322d3838393262662e737667)](https://camo.githubusercontent.com/990aa50be45969129fbabd33b67a75f2075e723f149d1adf4088bdd9e8b9e5e1/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f7068702d254532253839254135253230372e322d3838393262662e737667)[![CURL](https://camo.githubusercontent.com/f5a3b595480ac21ec43e745984c47d97fcc96f430547805750cd31928d67b28f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6355524c2d72657175697265642d677265656e2e737667)](https://camo.githubusercontent.com/f5a3b595480ac21ec43e745984c47d97fcc96f430547805750cd31928d67b28f/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6355524c2d72657175697265642d677265656e2e737667)

[![Latest Stable Version](https://camo.githubusercontent.com/5aebf9487b3c79929cf154ba5a23a64c980e899ffb1c4ca94739a0045ebddbb3/68747470733a2f2f706f7365722e707567782e6f72672f6c756b6173737339332f74656c656772616d626f742d7068702f762f737461626c65)](https://packagist.org/packages/lukasss93/telegrambot-php)[![Total Downloads](https://camo.githubusercontent.com/fc579b6b693ae32d54d3032fa065e5dcc5960086b89c71436db9e8ce76064e8b/68747470733a2f2f706f7365722e707567782e6f72672f6c756b6173737339332f74656c656772616d626f742d7068702f646f776e6c6f616473)](https://packagist.org/packages/lukasss93/telegrambot-php)[![License](https://camo.githubusercontent.com/a799c32c346d927888cb4da551d3280dc039f8cbfff889f441bdecac70658983/68747470733a2f2f706f7365722e707567782e6f72672f6c756b6173737339332f74656c656772616d626f742d7068702f6c6963656e7365)](https://packagist.org/packages/lukasss93/telegrambot-php)

> A very simple PHP [Telegram Bot API](https://core.telegram.org/bots/api) for sending messages.

Requirements
------------

[](#requirements)

- PHP ≥ 7.2
- Curl for PHP must be enabled.
- Telegram API Key, you can get one simply with [@BotFather](https://core.telegram.org/bots#botfather) with simple commands right after creating your bot.

For the WebHook:

- An SSL certificate (Telegram API requires this). You can use [Cloudflare's Free Flexible SSL](https://www.cloudflare.com/ssl) which crypts the web traffic from end user to their proxies if you're using CloudFlare DNS.
    Since the August 29 update you can use a self-signed ssl certificate.

For the GetUpdates:

- Some way to execute the script in order to serve messages (for example cronjob)

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

[](#installation)

You can install this library with composer:

`composer require lukasss93/telegrambot-php`

Configuration (WebHook)
-----------------------

[](#configuration-webhook)

Navigate to [https://api.telegram.org/bot(TOKEN)/setWebhook?url=https://yoursite.com/your\_update.php](https://api.telegram.org/bot(TOKEN)/setWebhook?url=https://yoursite.com/your_update.php)Or use the Telegram class setWebhook method.

Informations
------------

[](#informations)

This simple framework is object-based, all methods return a Telegram Object contained in TelegramBot/Types namespace.

Examples
--------

[](#examples)

```
use TelegramBot\TelegramBot;

$bot = new TelegramBot($token);
$update=$bot->getWebhookUpdate();
$bot->sendMessage([
    'chat_id' => $update->message->chat->id,
    'text' => 'Hello world!'
]);
```

If you want to get some specific parameter from the Telegram webhook, simply call parameter name in the object:

```
use TelegramBot\TelegramBot;

$bot = new TelegramBot($token);
$update=$bot->getWebhookUpdate();
$text=$update->message->text;
```

To upload a Photo or some other files, you need to load it with CurlFile:

```
// Load a local file to upload. If is already on Telegram's Servers just pass the resource id
$img = curl_file_create('test.png','image/png');
$bot->sendPhoto([
    'chat_id' => $chat_id,
    'photo' => $img
]);
```

To download a file on the Telegram's servers

```
$file = $bot->getFile($file_id);
$bot->downloadFile($file->file_path, "./my_downloaded_file_on_local_server.png");
```

If you want to use getUpdates instead of the WebHook you need a for cycle.

```
$updates=$bot->getUpdated();
for ($i = 0; $i < count($updates); $i++) {
    //single update
    $update=$updates[$i];
    if($update->message->getCommand()=='/start'){
        //working!
    }
}
```

Message Object Methods
----------------------

[](#message-object-methods)

Message object mainly provide 2 methods:

- getCommand()

    ```
    //$update->message->text => '/test@ExampleBot my args'
    $command=$update->message->getCommand();
    //$command => '/text'
    ```
- getArgs(bool $asString=false)

    ```
    //$update->message->text => '/test@ExampleBot my args'
    $args_array=$update->message->getArgs();
    //$args_array[0] => 'my'
    //$args_array[1] => 'args'
    $args_string=$update->message->getArgs(true);
    //$args_string => 'my args'
    ```

Build keyboard parameters
-------------------------

[](#build-keyboard-parameters)

Telegram's bots can have two different kind of keyboards: Inline and Reply. The InlineKeyboard is linked to a particular message, while the ReplyKeyboard is linked to the whole chat. They are both an array of array of buttons, which rapresent the rows and columns. For instance you can arrange a ReplyKeyboard using this code:

```
$buttons = [
    //First row
    [
        $bot->buildKeyboardButton("Button 1"),
        $bot->buildKeyboardButton("Button 2")
    ],
    //Second row
    [
        $bot->buildKeyboardButton("Button 3"),
        $bot->buildKeyboardButton("Button 4"),
        $bot->buildKeyboardButton("Button 5")],
    //Third row
    [
        $bot->buildKeyboardButton("Button 6")]
    ];

$bot->sendMessage([
    'chat_id' => $chat_id,
    'reply_markup' => $bot->buildKeyBoard($buttons),
    'text' => 'This is a Keyboard Test'
]);
```

When a user click on the button, the button text is send back to the bot. For an InlineKeyboard it's pretty much the same (but you need to provide a valid URL or a Callback data)

```
$buttons = [
    //First row
    [
        $bot->buildInlineKeyBoardButton("Button 1", $url="http://link1.com"),
        $bot->buildInlineKeyBoardButton("Button 2", $url="http://link2.com")
    ],
    //Second row
    [
        $bot->buildInlineKeyBoardButton("Button 3", $url="http://link3.com"),
        $bot->buildInlineKeyBoardButton("Button 4", $url="http://link4.com"),
        $bot->buildInlineKeyBoardButton("Button 5", $url="http://link5.com")
    ],
    //Third row
    [
        $bot->buildInlineKeyBoardButton("Button 6", $url="http://link6.com")
    ]
];

$bot->sendMessage([
    'chat_id' => $chat_id,
    'reply_markup' => $bot->buildInlineKeyBoard($buttons),
    'text' => 'This is a Keyboard Test'
]);
```

This is the list of all the helper functions to make keyboards easily:

```
$bot->buildKeyBoard(array $options, $onetime=true, $resize=true, $selective=true);
```

Send a custom keyboard. $option is an array of array KeyboardButton.
Check [ReplyKeyBoardMarkUp](https://core.telegram.org/bots/api#replykeyboardmarkup) for more info.

```
$bot->buildInlineKeyBoard(array $inline_keyboard);
```

Send a custom keyboard. $inline\_keyboard is an array of array InlineKeyboardButton.
Check [InlineKeyboardMarkup](https://core.telegram.org/bots/api#inlinekeyboardmarkup) for more info.

```
$bot->buildInlineKeyBoardButton($text, $url, $callback_data, $switch_inline_query);
```

Create an InlineKeyboardButton.
Check [InlineKeyBoardButton](https://core.telegram.org/bots/api#inlinekeyboardbutton) for more info.

```
$bot->buildKeyBoardButton($text, $url, $request_contact, $request_location);
```

Create a KeyboardButton.
Check [KeyBoardButton](https://core.telegram.org/bots/api#keyboardbutton) for more info.

```
$bot->buildKeyBoardHide($selective=true);
```

Hide a custom keyboard.
Check [ReplyKeyBoarHide](https://core.telegram.org/bots/api#replykeyboardhide) for more info.

```
$bot->buildForceReply($selective=true);
```

Show a Reply interface to the user.
Check [ForceReply](https://core.telegram.org/bots/api#forcereply) for more info.

Contact me
----------

[](#contact-me)

You can contact me [via Telegram](https://telegram.me/Lukasss93) but if you have an issue please [open](https://github.com/Lukasss93/telegrambot-php/issues) one.

To-Do list
----------

[](#to-do-list)

- Optional predictive parameters in methods
- Optimize keyboards
- Chat conversations
- Commands listener with callback + events

Changelog
---------

[](#changelog)

All notable changes to this project will be documented [here](CHANGELOG.md).

###  Health Score

40

—

FairBetter than 86% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity27

Limited adoption so far

Community16

Small or concentrated contributor base

Maturity81

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 50.5% 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 ~43 days

Recently: every ~101 days

Total

45

Last Release

1569d ago

Major Versions

v1.14.1 → 2.x-dev2022-04-21

PHP version history (5 changes)1.0.0PHP &gt;=5.3

1.4.0PHP &gt;=5.6

1.7PHP &gt;=7.2

v1.14.1PHP ^7.2|^8.0

2.x-devPHP ^8.0

### Community

Maintainers

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

---

Top Contributors

[![Eleirbag89](https://avatars.githubusercontent.com/u/10547598?v=4)](https://github.com/Eleirbag89 "Eleirbag89 (99 commits)")[![Lukasss93](https://avatars.githubusercontent.com/u/4071613?v=4)](https://github.com/Lukasss93 "Lukasss93 (91 commits)")[![happy-code-com](https://avatars.githubusercontent.com/u/2848403?v=4)](https://github.com/happy-code-com "happy-code-com (2 commits)")[![ivmaks](https://avatars.githubusercontent.com/u/13006295?v=4)](https://github.com/ivmaks "ivmaks (2 commits)")[![xpyctum](https://avatars.githubusercontent.com/u/6584811?v=4)](https://github.com/xpyctum "xpyctum (2 commits)")

---

Tags

apibotcomposerframeworkinstantlibrarymessagingtelegram

### Embed Badge

![Health badge](/badges/lukasss93-telegrambot-php/health.svg)

```
[![Health](https://phpackages.com/badges/lukasss93-telegrambot-php/health.svg)](https://phpackages.com/packages/lukasss93-telegrambot-php)
```

###  Alternatives

[phan/phan

A static analyzer for PHP

5.6k12.1M1.3k](/packages/phan-phan)[pocketmine/pocketmine-mp

A server software for Minecraft: Bedrock Edition written in PHP

3.6k79.3k91](/packages/pocketmine-pocketmine-mp)[felixfbecker/advanced-json-rpc

A more advanced JSONRPC implementation

25482.2M6](/packages/felixfbecker-advanced-json-rpc)[cloudconvert/cloudconvert-php

PHP SDK for CloudConvert APIs

2263.7M8](/packages/cloudconvert-cloudconvert-php)[seatsio/seatsio-php

A PHP client for the seats.io API

17818.8k](/packages/seatsio-seatsio-php)[keepa/php_api

API Framework for Keepa.com

57502.8k](/packages/keepa-php-api)

PHPackages © 2026

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