PHPackages                             tg/tgwebvalid - 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. tg/tgwebvalid

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

tg/tgwebvalid
=============

An easy way to validate Telegram Login Widget and Telegram Mini App users on your website using PHP

v4.2.5(1mo ago)6821.7k↓13.2%22[4 issues](https://github.com/CrazyTapok-bit/tgWebValid/issues)1MITPHPPHP ^8.2CI passing

Since Mar 12Pushed 1y ago2 watchersCompare

[ Source](https://github.com/CrazyTapok-bit/tgWebValid)[ Packagist](https://packagist.org/packages/tg/tgwebvalid)[ Docs](https://tgwebvalid.com/en/)[ Patreon](https://www.patreon.com/user?u=99188087)[ RSS](/packages/tg-tgwebvalid/feed)WikiDiscussions 4.x Synced 1mo ago

READMEChangelog (10)Dependencies (6)Versions (21)Used By (1)

Library for Telegram Web App User Validation and Telegram Login Widget for PHP
==============================================================================

[](#library-for-telegram-web-app-user-validation-and-telegram-login-widget-for-php)

[![Testing Status](https://github.com/CrazyTapok-bit/tgWebValid/workflows/PHP%20CI/badge.svg)](https://github.com/CrazyTapok-bit/tgWebValid/actions)[![Minimum PHP Version](https://camo.githubusercontent.com/34f283c5df192f53497bf7d0a5c8d8e0f9d2fd0e431e07b40e4e554e413345aa/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646570656e64656e63792d762f74672f746777656276616c69642f706870)](https://packagist.org/packages/tg/tgwebvalid)[![Latest version](https://camo.githubusercontent.com/e660733279e9ad601e8a826cc46168cb676176e795026622aee84c0cf5b70b33/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f74672f746757656256616c6964)](https://packagist.org/packages/tg/tgwebvalid)[![Downloads](https://camo.githubusercontent.com/ddcce6f0ac801c25876d9aa6af916897e9df3b9f693f38ffa9f3a70d35f7bfb3/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f64742f74672f746777656276616c69642e737667)](https://packagist.org/packages/tg/tgwebvalid)[![License](https://camo.githubusercontent.com/9eebaae0e42121f5441b0b03719273c131f70a700b13fc62c7ac9b40f3f60754/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f6c2f74672f746777656276616c6964)](https://packagist.org/packages/tg/tgwebvalid)

[![Documentation](https://camo.githubusercontent.com/148aad97b3ee9223f205f64027a4cfe8acf2221e65e96113f823256bce8bb431/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f253230446f63756d656e746174696f6e2d746777656276616c69642e636f6d2d626c75653f6c6f676f3d646174613a696d6167652f706e673b6261736536342c6956424f5277304b47676f414141414e53556845556741414144494141414179434159414141416550346978414141414358424957584d41414173544141414c457745416d7077594141414639456c45515652346e4f326136573957565244475732684239494f4169697a47445347616d4567694342672b53465255434d53396747674d424a585644534d714f7845424259314252596c4b3949502f41496b43797549536a566977794b496f49465a424a536b756e796a4c7a3078395468324f393733337675324c4e4b5a503071526e7a7379634f32655a4d7a506e4c53747278663855514366674e75413559445777433667446a7572502f763947666338437477496479316f43674e4f414d6344377742474b68386d734255616272724a545a4d436a774d2f756f327a576a376d32666542513178347167774f4f53536267415041773050362f4d754a71594b6637674b2b415234445a6270596e4f2f344775505a555a3841737957357a2b725944413037324b697831733237372f553667484f6748314150486762475233416d4769445a65354d4e41582b6d6f6b733677756b744b767433735541496675686d664156536f72774c596f72356c43624c2f4d6b5430563953314f644931303532334463435a70544b694f31416a7858754171364c2b436572624333516f7770417a67422f5566582f5531312f3644463843585a747278446e41626e6357756b58396c63412b395938716f4350524550574e635a4e516d5443424e716268572b437370687068792f79424650304f39457a3545444f6d62524d4d73544671785449366f622b6e786a61734b5452476c69463261586e3843547750394859387764415a4b586f4b47714a2b4f784f47745937575732505a6d42344c697a58694a6e6b673830526a6756567142396a686e69385056702b3268334d59306b3036544e6438357a6a516d4b76304463457244736c72524164334c7035773944374147384368614a624d6861365846356f453343683333464e685330416e3066714a5a374a6b4e75676a50656f30566838332f67783358724c64736d355877343734414b712f4854446348664a5359703930747973776272686e706d595a3064364648634d7a6543326b4d467744584b384a574b4767634250776e5762577a374c5250686650613842446b6a556468674d5a593934737676314a786e72477538533431573762464c377a7850636230435a6a38415a6b384a53374c64736a67792b454d315670436933514d7a79514d6641493861314c3438747269506a576958564542702b64513850717444436b586e2b706c77387756386f576c64435178574b646b2b4f5344742f5a4b5574764b316f452b436650474f6c6f55357a6e6d65376f493058375175305146393264454641615a6a723637614c5671503231326e63344872746e69434d487063694737576d475043326d74787a744d366577327448664675334a364e79383433672b64724a624866314e3057617276556a746c59376e55796462342b6976697a59767a52424c636777484c5544545458786359594e6c626f5a4c7a4f5543763668397162763577333168776544356b743368567573797556433742777958533361413272394b6478693378726e6249507554326c656b47564c75627577424c71423754476d7059546f7755503976692b52446144504977707577597670442b734a6b3759724744564677667a66753438425443624a37436872686c4c34596c6b367259444e7a675a756c6167563368726d52724b576e6867566142654f2f53504c4864644747334835424a4c73735964774c4338686d756e31544f4e68744c384f4768504d535a7138787146502f6f456a3245396633555354624c354b394e704c646d484457476c63746a79467474566344786b635645416f74722f5a3332502b475351553832506478434b527a64644478334f66364a6a70366256723446482b516864416852472b3835594575726a4351754c7a41712b6f33766e4d6476625030475a59576b4632702f684f6969306a3268567847744b4b6c674c2b4478735061456c3079654f646f6d52666e304e7541496d6f45733573644e4c6f77666b494c44754d6e692b2b3950496e567a725345795a4966386631526f7353716a53763764452f684b336352526c56577172732f35387a3456486549533358584b4e586448525571446f6d32535477724a464e4d716e754c2b48354d54585846504d3674536b737450747962616f5337454774385a4a7452447170584f65686c585677334b4361365741346b6f4b4e6f6663557a55544c72633561445a71707653395a3239735a636c31476732367959714e5146756e6e536e56616747357a4c69495163476e65774c536a736c65446c6d6c4d796e5a56514d75326c7357784d6a32654b4d734a747362555a525778372b3050504178584647714c34796735756e694c32366959567361586f624a556f55594c545065465a59572b6844386c68794430707a776f3958464a6c4c3853646d325345553968566a793168774250653936774735694c6130347438364b6b74384e417a555072433457344d507074726a486d636a564a3852507536306d3250634542664b734b5135657171646b39766c51702f53762f30466a32474c6e45767372745553576b6a6c7872433748465a686c697549624c4a58436b646f39773250716f66487079387433666c3869464d5150395063393748506d4a4b49554f414236506e36576b7155415273793555426c7369593971716b37302f35775944394f4743596177397a4c31784a50786777377a55314d2f51346951614e557577553338353555432b33576e564b4445694348556f4664565a7365316656777a6f643343503666366636467571746f3751487552566c4c51642f41575434796b6b69796643394141414141456c46546b5375516d4343)](https://tgwebvalid.com/)[![StandWithUkraine](./badges/StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)[![StandWithUkraine](./badges/RussianWarship.svg)](https://stand-with-ukraine.pp.ua)

[![StandWithUkraine](./StandWithUkraine.svg)](https://stand-with-ukraine.pp.ua)

About TgWebValid
----------------

[](#about-tgwebvalid)

They say we are cool 😎

⭐️ Support us, give us a star on GitHub and become our sponsor 😊

🙏 Please let us know on GitHub if something isn't working for you or if you need additional functionality

---

User authentication occurs by encrypting the received, raw, user data and comparing it with the hash provided by the telegram. A failed check can be equated with a possible attempt to bypass or hack the system.

The library verifies users Telegram Login Widget and Telegram Web App

`WARNING`: Use user data only after successful authentication

To quickly and safely verify a user, we recommend following a few simple steps

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

[](#installation)

You can install the TgWebValid library through the [composer](https://getcomposer.org/) package manager by executing the command

```
composer require tg/tgwebvalid
```

Add the `--no-dev` flag to install only the dependencies needed to run your project in a production environment.

Using
-----

[](#using)

The first thing you need to do is to set in the constructor of the TgWebValid class the token of the Telegram bot on behalf of which authentication is performed by default. And store the result in a variable.

Also, if you want to throw an exception in case of a validation error, set the second parameter to true. But be sure to use the `try catch` structure

```
