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

ActiveLibrary[API Development](/categories/api)

romanlazko/laravel-telegram
===========================

Telegram Api for Laravel

1.0.2(1y ago)025MITPHPPHP ^8.1

Since Apr 5Pushed 1y ago1 watchersCompare

[ Source](https://github.com/romanlazko/laravel-telegram)[ Packagist](https://packagist.org/packages/romanlazko/laravel-telegram)[ RSS](/packages/romanlazko-laravel-telegram/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (6)DependenciesVersions (7)Used By (0)

Laravel Telegram Bot Integration
================================

[](#laravel-telegram-bot-integration)

[![Latest Version](https://camo.githubusercontent.com/38afaed94e5751ff0d467cb4aa7f72d18c3e1f61714f599159af74375ddf6127/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f726f6d616e6c617a6b6f2f6c61726176656c2d74656c656772616d2e7376673f7374796c653d666c61742d737175617265)](https://packagist.org/packages/romanlazko/laravel-telegram)[![License](https://camo.githubusercontent.com/b97854ed90469ee0042e2fda9bda843fa02d895d09c766b2b4a7ede5626aada4/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f726f6d616e6c617a6b6f2f6c61726176656c2d74656c656772616d2e7376673f7374796c653d666c61742d737175617265)](LICENSE)

The `laravel-telegram` package provides a seamless integration between Laravel applications and the [Telegram Bot API](https://core.telegram.org/bots/api). It enables developers to easily build Telegram bots with clean, expressive Laravel syntax, and supports features such as:

- Bot creation and registration via Artisan
- Webhook management
- Command-based architecture
- Automatic injection of Telegram update data (Chat, Message, CallbackQuery, etc.)
- Full support for Laravel queues

---

🚀 Installation
--------------

[](#-installation)

Install the package using Composer:

```
composer require romanlazko/laravel-telegram
```

### Optional: Publish Migrations

[](#optional-publish-migrations)

```
php artisan vendor:publish --tag=laravel-telegram-migrations
```

---

🤖 Create a Bot
--------------

[](#-create-a-bot)

Use the following command to register a bot with your Laravel application:

```
php artisan telegram:bot YOUR_BOT_TOKEN
```

This will generate a new service provider at:

```
app/Providers/Telegram/BotNameProvider.php

```

### Registering the Provider

[](#registering-the-provider)

Ensure the generated service provider is registered:

- **Laravel 11+**: in `bootstrap/providers.php`
- **Laravel 10 and below**: in `config/app.php` under the `providers` array

Add it manually if it was not auto-registered.

---

🌐 Set the Webhook
-----------------

[](#-set-the-webhook)

To set the Telegram webhook for your bot:

```
php artisan telegram:set-webhook telegram_bot_id
```

The webhook URL defaults to:

```
https://your-app-url.com/api/telegram-webhook/{telegram_bot_id}

```

### Local Development

[](#local-development)

Use [ngrok](https://ngrok.com) to expose your local server:

```
ngrok http 8000
```

Then update `.env`:

```
APP_URL=https://your-ngrok-url.ngrok.io
```

Re-run the webhook command after updating the URL.

---

📦 Creating Commands
-------------------

[](#-creating-commands)

Commands are the main way to handle user interactions with the bot. Each command is a Laravel Job that responds to Telegram updates.

Generate a new command with:

```
php artisan telegram:command DefaultCommand
```

This creates a file at:

```
app/Telegram/BotName/Commands/DefaultCommand.php

```

---

✨ Example Command
-----------------

[](#-example-command)

```
namespace App\Telegram\MyBot\Commands;

use Romanlazko\LaravelTelegram\Command;
use Romanlazko\LaravelTelegram\Models\Types\Chat;

class DefaultCommand extends Command
{
    public function execute(Chat $chat)
    {
        $this->apiMethod('sendMessage');
        $this->text('My first command!');
        $this->chatId($chat->id);
        $this->parseMode('Markdown');

        return $this->send();
    }

    public function resolveDefaultClosureDependencyForEvaluationByName(string $parameterName): array
    {
        return match ($parameterName) {
            'update' => [$this->getObject()],
            'message' => [$this->evaluate(fn ($update) => $update->message ?? $update->callback_query->message)],
            'chat' => [$this->evaluate(fn ($message) => $message->chat)],
            default => parent::resolveDefaultClosureDependencyForEvaluationByName($parameterName),
        };
    }
}
```

---

🧠 Dependency Injection
----------------------

[](#-dependency-injection)

Your command’s `execute()` method can declare parameters like:

- `Update`
- `Message`
- `Chat`
- `CallbackQuery`

These will be resolved and injected automatically from the incoming Telegram update.

You can override the method `resolveDefaultClosureDependencyForEvaluationByName()` to customize how dependencies are resolved.

---

✅ Features at a Glance
----------------------

[](#-features-at-a-glance)

- Support for multiple bots
- Laravel-native syntax
- Webhook auto-registration
- Commands as Laravel Jobs
- Dependency injection
- Clean architecture

---

📚 Resources
-----------

[](#-resources)

- [Telegram Bot API](https://core.telegram.org/bots/api)
- [Laravel Service Providers](https://laravel.com/docs/providers)
- [Laravel Queues](https://laravel.com/docs/queues)

---

📝 License
---------

[](#-license)

This package is open-sourced software licensed under the [MIT license](LICENSE).

---

💬 Support
---------

[](#-support)

Feel free to open issues or contribute with PRs. Happy bot building 🤖!

###  Health Score

30

—

LowBetter than 64% of packages

Maintenance47

Moderate activity, may be stable

Popularity8

Limited adoption so far

Community7

Small or concentrated contributor base

Maturity50

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

Every ~1 days

Total

6

Last Release

395d ago

Major Versions

0.0.3 → 1.02025-04-06

### Community

Maintainers

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

---

Top Contributors

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

### Embed Badge

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

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

###  Alternatives

[stripe/stripe-php

Stripe PHP Library

4.0k143.3M480](/packages/stripe-stripe-php)[twilio/sdk

A PHP wrapper for Twilio's API

1.6k92.9M272](/packages/twilio-sdk)[knplabs/github-api

GitHub API v3 client

2.2k15.8M187](/packages/knplabs-github-api)[facebook/php-business-sdk

PHP SDK for Facebook Business

90121.9M34](/packages/facebook-php-business-sdk)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)[google/gax

Google API Core for PHP

263103.1M454](/packages/google-gax)

PHPackages © 2026

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