PHPackages                             fahriztx/telman - 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. fahriztx/telman

ActiveLibrary[API Development](/categories/api)

fahriztx/telman
===============

Laravel package for Telegram Manager API client with webhook handler

v0.0.2(1w ago)00MITPHPPHP ^8.1CI passing

Since May 29Pushed 1w agoCompare

[ Source](https://github.com/FAHRIZTX/telman)[ Packagist](https://packagist.org/packages/fahriztx/telman)[ RSS](/packages/fahriztx-telman/feed)WikiDiscussions master Synced 1w ago

READMEChangelog (2)Dependencies (3)Versions (2)Used By (0)

Telman — Laravel Package for Telegram Manager API
=================================================

[](#telman--laravel-package-for-telegram-manager-api)

A Laravel package that provides a clean client and webhook handler for the Telegram Manager API. Instead of using bot tokens directly, this package routes requests through a Telegram Manager proxy.

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

[](#installation)

```
composer require fahriztx/telman
```

Configuration
-------------

[](#configuration)

Publish the config file:

```
php artisan vendor:publish --tag=telman-config
```

Add the following to your `.env`:

```
TELMAN_BASE_URL=https://your-host/api/v1
TELMAN_API_KEY=tgm_live_your_api_key
TELMAN_BOT_ID=your_bot_id
TELMAN_WEBHOOK_SECRET=your_webhook_secret
```

### Config Options

[](#config-options)

KeyDescriptionDefault`base_url`Telegram Manager API base URL`https://your-host/api/v1``api_key`API key for authentication`null``bot_id`Bot ID for requests`null``webhook_secret`Secret for webhook signature verification`null``webhook_prefix`URL prefix for webhook routes`telman``enable_webhook`Auto-register webhook routes`true`Usage
-----

[](#usage)

### Sending Messages

[](#sending-messages)

```
use Fahriztx\Telman\TelmanFacade as Telman;

// Simple text message
Telman::text(123456789, 'Hello from Laravel!');

// With inline keyboard
Telman::sendMessage([
    'chat_id' => 123456789,
    'text' => 'Order #2437234 confirmed!',
    'reply_markup' => Telman::inlineKeyboard([
        [['text' => 'Open', 'url' => 'https://example.com/order/2437234']],
    ]),
]);

// With callback buttons (JSON-encoded callback_data)
Telman::sendMessage([
    'chat_id' => 123456789,
    'text' => 'Confirm order #2437234?',
    'reply_markup' => Telman::inlineKeyboard([
        [
            ['text' => 'Yes', 'callback_data' => json_encode(['orderId' => '2437234', 'status' => 'confirm'])],
            ['text' => 'No', 'callback_data' => json_encode(['orderId' => '2437234', 'status' => 'reject'])],
        ],
    ]),
]);
```

### Sending Photos (Multipart)

[](#sending-photos-multipart)

```
Telman::sendPhotoMultipart([
    'chat_id' => 123456789,
    'caption' => 'Here is your photo',
], '/path/to/photo.jpg');
```

### Dynamic Method Calls

[](#dynamic-method-calls)

Any Telegram Bot API method can be called dynamically:

```
// sendMessage
Telman::sendMessage([
    'chat_id' => 123456789,
    'text' => 'Hello!',
]);

// editMessageText
Telman::editMessageText([
    'chat_id' => 123456789,
    'message_id' => 42,
    'text' => 'Updated text!',
]);

// deleteMessage
Telman::deleteMessage([
    'chat_id' => 123456789,
    'message_id' => 42,
]);
```

Webhook Handler
---------------

[](#webhook-handler)

The webhook route is automatically registered at `POST /{webhook_prefix}/webhook` (default: `/telman/webhook`).

### Registering Callback Handlers

[](#registering-callback-handlers)

Callback data is expected to be JSON-encoded with a `status` field for routing:

```
use Fahriztx\Telman\WebhookHandler;
use Fahriztx\Telman\TelmanFacade as Telman;

// Handler for confirm status
WebhookHandler::on('confirm', function ($data, $update) {
    $orderId = $data['orderId'];
    Order::where('id', $orderId)->update(['status' => 'confirmed']);

    Telman::sendMessage([
        'chat_id' => $update['callback_query']['from']['id'],
        'text' => "Order #{$orderId} confirmed! ✅",
    ]);
});

// Handler for reject status
WebhookHandler::on('reject', function ($data, $update) {
    $orderId = $data['orderId'];
    Order::where('id', $orderId)->update(['status' => 'rejected']);

    Telman::sendMessage([
        'chat_id' => $update['callback_query']['from']['id'],
        'text' => "Order #{$orderId} rejected. ❌",
    ]);
});

// Fallback for all unhandled callbacks
WebhookHandler::on('*', function ($data, $update) {
    \Illuminate\Support\Facades\Log::info('Unhandled callback: ' . json_encode($data));
});

// Handle incoming messages
WebhookHandler::handleMessage(function ($message, $update) {
    \Illuminate\Support\Facades\Log::info('Message: ' . $message['text']);
});
```

### Setting Up Webhook in Telegram Manager

[](#setting-up-webhook-in-telegram-manager)

Point your Telegram Manager webhook URL to:

```
https://your-app.com/telman/webhook

```

(Or whatever prefix you configured in `webhook_prefix`.)

Rate Limit Handling
-------------------

[](#rate-limit-handling)

```
use Fahriztx\Telman\TelmanException;

try {
    Telman::sendMessage([...]);
} catch (TelmanException $e) {
    if ($e->retryAfter()) {
        sleep($e->retryAfter());
        Telman::sendMessage([...]);
    }
}
```

Disabling Webhook Routes
------------------------

[](#disabling-webhook-routes)

Set `enable_webhook` to `false` in your config:

```
// config/telman.php
return [
    'enable_webhook' => false,
];
```

Exception Handling
------------------

[](#exception-handling)

The `TelmanException` provides access to the full API response parameters:

```
use Fahriztx\Telman\TelmanException;

try {
    Telman::sendMessage([...]);
} catch (TelmanException $e) {
    // Error description
    echo $e->getMessage();

    // HTTP status code
    echo $e->getCode();

    // Retry-after value (if rate limited)
    if ($retryAfter = $e->retryAfter()) {
        echo "Retry after {$retryAfter} seconds";
    }

    // Full response parameters
    $params = $e->parameters;
}
```

License
-------

[](#license)

MIT

###  Health Score

35

—

LowBetter than 77% of packages

Maintenance98

Actively maintained with recent releases

Popularity0

Limited adoption so far

Community6

Small or concentrated contributor base

Maturity32

Early-stage or recently created project

 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

11d ago

### Community

Maintainers

![](https://www.gravatar.com/avatar/6b15079ff37fb75f261e61099eeb6403857dfc13d52de2e8773ff1ed8716ff29?d=identicon)[fahriztx](/maintainers/fahriztx)

---

Top Contributors

[![FAHRIZTX](https://avatars.githubusercontent.com/u/23007278?v=4)](https://github.com/FAHRIZTX "FAHRIZTX (2 commits)")

### Embed Badge

![Health badge](/badges/fahriztx-telman/health.svg)

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

###  Alternatives

[psalm/plugin-laravel

Psalm plugin for Laravel

3325.1M337](/packages/psalm-plugin-laravel)[spatie/laravel-export

Create a static site bundle from a Laravel app

670139.5k6](/packages/spatie-laravel-export)[simplestats-io/laravel-client

Analytics for Laravel. Track visitors, registrations, and payments. Discover which channels actually drive revenue, not just traffic. Server-side, GDPR compliant, ad-blocker proof.

5019.3k](/packages/simplestats-io-laravel-client)[jasara/php-amzn-selling-partner-api

A fluent interface for Amazon's Selling Partner API in PHP

1348.1k1](/packages/jasara-php-amzn-selling-partner-api)[fleetbase/core-api

Core Framework and Resources for Fleetbase API

1232.2k16](/packages/fleetbase-core-api)

PHPackages © 2026

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