PHPackages                             garphild/auth-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. [Authentication &amp; Authorization](/categories/authentication)
4. /
5. garphild/auth-telegram

ActiveLibrary[Authentication &amp; Authorization](/categories/authentication)

garphild/auth-telegram
======================

Telegram auth

1.0.5(5y ago)3241MITPHP

Since Nov 7Pushed 5y ago1 watchersCompare

[ Source](https://github.com/Garphild/auth-telegram)[ Packagist](https://packagist.org/packages/garphild/auth-telegram)[ RSS](/packages/garphild-auth-telegram/feed)WikiDiscussions main Synced today

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

Auth by telegram
================

[](#auth-by-telegram)

PHP wrapper for the Telegram login widget. The Telegram login widget is a simple way to authorize users on your website.

Useful links:

- [How to create bot](https://core.telegram.org/bots#3-how-do-i-create-a-bot)
- [More about telegram login](https://core.telegram.org/widgets/login)

Features:

- async/sync load
- different button sizes
- user's photo
- configurable button corner radius
- authentificate result can be sent to callback or reirection url
- get write to user permission

Constructor params
------------------

[](#constructor-params)

- **$botName**: string - bot name
- **$botKey**: string - bot auth key
- **$cookieName**: string - cookie name to store auth data
- **$config**: string - config array for widget

Config options
--------------

[](#config-options)

- **size**: string enum('large', 'medium', 'small'\] - size of button
- **userPhoto**: boolean - get user's photo in auth result
- **cornerRadius**: number - button corner radius
- **resultActionType**: string enum('callback', 'url') - button corner radius
- **resultAction**: string - callback javascript function name or url to redirect
- **requestWrite**: boolean - allow get write messages to user permission
- **async**: boolean - allow async script load
- **maxAge**: number - max age of auth data to be actual

Public properties
-----------------

[](#public-properties)

- **user** TelegramUserModel - authentificated user data or null

Public methods
--------------

[](#public-methods)

- **isAuthentificated(): boolean** - check if user authentificated (based on cookie)
- **getWidget(): string** - get widget html code
- **logOut(): void** - clear cookie and user data
- **setUser(TelegramUserModel $user): void** - set current user
- **clearUser(): void** - clear current user
- **checkTelegramAuthorization($auth\_data): void** - check data from telegram

Usage
=====

[](#usage)

Basic usage
-----------

[](#basic-usage)

```
require_once "./vendor/autoload.php";

use Garphild\AuthTelegram\TelegramAuthentificator;

define('BOT_USERNAME', 'XXXXXXX'); // place username of your bot here
define('BOT_KEY', 'XXXXX:XXXXXXXXX'); // place @botFather key of your bot here
define('BOT_COOKIE_NAME', 'XXXXXX'); // place cookie name to store data
$config = [
  ...
];
$tgAuth = new TelegramAuthentificator(BOT_USERNAME, BOT_KEY, BOT_COOKIE_NAME, $config);

```

Redirect
--------

[](#redirect)

See examples folder. This is simple examples. Don't use in production. Use sessions to store data or JWT keys or any secure method.

login\_example.php

```
require_once "./vendor/autoload.php";

use Garphild\AuthTelegram\TelegramAuthentificator;

define('BOT_USERNAME', 'XXXXXXX'); // place username of your bot here
define('BOT_KEY', 'XXXXX:XXXXXXXXX'); // place @botFather key of your bot here
define('BOT_COOKIE_NAME', 'XXXXXX'); // place cookie name to store data
$config = [
  'resultActionType' => 'url',
  'resultAction' => 'check_authorization.php',
  ...
];
$tgAuth = new TelegramAuthentificator(BOT_USERNAME, BOT_KEY, BOT_COOKIE_NAME, $config);
if (isset($_COOKIE["tg_user"])) {
    $tgAuth->setUser(new TelegramUserModel(json_decode($_COOKIE["tg_user"], true)));
}

if ($_GET['logout']) {
  $tgAuth->logOut();
  setcookie("tg_user", null);
}

if ($tgAuth->isAuthentificated()) {
    ... user authentificated ...
} else {
    ... not authentificated ...
    echo $tgAuth->getWidget();
}

```

check\_authorization.php

```
require_once "./vendor/autoload.php";

use Garphild\AuthTelegram\TelegramAuthentificator;

define('BOT_USERNAME', 'XXXXXXX'); // place username of your bot here
define('BOT_KEY', 'XXXXX:XXXXXXXXX'); // place @botFather key of your bot here
define('BOT_COOKIE_NAME', 'XXXXXX'); // place cookie name to store data
$config = [
  ...
];
$tgAuth = new TelegramAuthentificator(BOT_USERNAME, BOT_KEY, BOT_COOKIE_NAME, $config);

try {
  $tgAuth->logIn($_GET);
  setcookie("tg_user", json_encode($tgAuth->user));
} catch (Exception $e) {
  die ($e->getMessage());
}

header('Location: login_example.php');

```

After success login user's info available as $tgAuth-&gt;user.

###  Health Score

26

—

LowBetter than 41% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity11

Limited adoption so far

Community8

Small or concentrated contributor base

Maturity54

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

2064d ago

### Community

Maintainers

![](https://avatars.githubusercontent.com/u/7926288?v=4)[garphild](/maintainers/garphild)[@Garphild](https://github.com/Garphild)

---

Top Contributors

[![Garphild](https://avatars.githubusercontent.com/u/7926288?v=4)](https://github.com/Garphild "Garphild (8 commits)")

###  Code Quality

TestsPHPUnit

### Embed Badge

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

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

###  Alternatives

[kartik-v/yii2-password

Useful password strength validation utilities for Yii Framework 2.0

761.3M17](/packages/kartik-v-yii2-password)[vitalybaev/laravel5-dkim

Laravel 5/6 package for signing outgoing messages with DKIM.

3163.1k](/packages/vitalybaev-laravel5-dkim)

PHPackages © 2026

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