PHPackages                             alexsisukin/php-telegram-cli-client - 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. alexsisukin/php-telegram-cli-client

ActiveLibrary[API Development](/categories/api)

alexsisukin/php-telegram-cli-client
===================================

php-client for telegram-cli

v0.4.2(8y ago)0333MPL-2.0PHPPHP &gt;=5.3.0

Since Feb 18Pushed 8y ago1 watchersCompare

[ Source](https://github.com/Alexsisukin/php-telegram-cli-client)[ Packagist](https://packagist.org/packages/alexsisukin/php-telegram-cli-client)[ Docs](https://github.com/zyberspace/php-telegram-cli-client)[ RSS](/packages/alexsisukin-php-telegram-cli-client/feed)WikiDiscussions master Synced today

READMEChangelog (1)Dependencies (1)Versions (8)Used By (0)

\###Update 2015-12-23:

**As i currently have no time to work on this project anymore and telegram released its own [bot-api](https://core.telegram.org/bots), there won't be many new updates to this project in the future. I will try to go through all currently open issues so there is nothing left in the issue section anymore (even if i need to close some things with `wontfix`).
If someone wants to takeover this project i am willing to give him push-rights or link to his fork on github/packagist.**

**If you want to port your project to the new bot-api take a look at the [unofficial php-sdk](https://github.com/irazasyed/telegram-bot-sdk).**

---

zyberspace/telegram-cli-client
==============================

[](#zyberspacetelegram-cli-client)

php-client for [telegram-cli](https://github.com/vysheng/tg/)

[![Packagist](https://camo.githubusercontent.com/750b4b1e751d3fafe6f172bc2017fba1da7991d5d4fb73851f8938e869736bf9/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f762f7a7962657273706163652f74656c656772616d2d636c692d636c69656e742e737667)](https://packagist.org/packages/zyberspace/telegram-cli-client)[![Codacy](https://camo.githubusercontent.com/5a85bf597660c7bea614dbdf341eb7d1e6bb975604e09ae8e884dda5d7f37aa2/68747470733a2f2f7777772e636f646163792e636f6d2f70726f6a6563742f62616467652f3431373561396262663838353437636462643934636635376334353730363864)](https://www.codacy.com/app/zyberspace/php-telegram-cli-client)[![License](https://camo.githubusercontent.com/87d4d65c475af702b451a0acf6c1999522b02e582df4956c9f9058914c2658df/68747470733a2f2f696d672e736869656c64732e696f2f6769746875622f6c6963656e73652f7a7962657273706163652f7068702d74656c656772616d2d636c692d636c69656e742e737667)](https://www.mozilla.org/MPL/2.0/)

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

[](#requirements)

- a running [telegram-cli](https://github.com/vysheng/tg/) listening on a unix-socket (`-S`) or a port (`-P`) and returning all answers as JSON (`--json`).
    Needs to be configured already (phone-number, etc.).
- php &gt;= 5.3.0

Usage
-----

[](#usage)

\###Setup telegram-cli [telegram-cli](https://github.com/vysheng/tg/) needs to run on a unix-socket (`-S`) or a port (`-P`), so *telegram-cli-client* can connect to it. All answers need to be returned as JSON (`--json`).
You should also start it with `-W` so the contact-list gets loaded on startup.
For this example we will take the following command (execute it from the dir, where you installed telegram-cli, not the php-client), `-d` lets it run as daemon.:

```
./bin/telegram-cli --json -dWS /tmp/tg.sck &
```

If you run the telegram-cli under another user than your php-script and you are using linux, you need to change the rights of the socket so that the php-script can access it (thanks to [dennydai](https://github.com/dennydai) for this!).
For example, add both to a `telegram`-group and then do

```
chown :telegram /tmp/tg.sck
chmod g+rwx /tmp/tg.sck
```

If you never started telegram-cli before, you need to start it first in normal mode, so you can type in your telegram-phone-number and register it, if needed (`./bin/telegram-cli`).

To stop the daemon use `killall telegram-cli` or `kill -TERM [telegram-pid]`.

\###Install telegram-cli-client with composer In your project-root:

```
composer require --update-no-dev zyberspace/telegram-cli-client
```

Composer will then automatically add the package to your project requirements and install it (also creates the `composer.json` if you don't have one already).
If you want to use the discovery-shell, remove the `--update-no-dev` from the command.

\###Use it

```
require('vendor/autoload.php');
$telegram = new \Zyberspace\Telegram\Cli\Client('unix:///tmp/tg.sck');

$contactList = $telegram->getContactList();
$telegram->msg($contactList[0]->print_name, 'Hey man, what\'s up? :D');
```

\###Use it with the discovery-shell A really easy way to learn the api is by using the embedded [discover-shell](https://github.com/zyberspace/php-discovery-shell). You need to install the dev-dependencies for this (`composer update --dev`).

```
$ ./discovery-shell.php
-- discovery-shell to help discover a class or library --

Use TAB for autocompletion and your arrow-keys to navigate through your method-history.
Beware! This is not a full-featured php-shell. The input gets parsed with PHP-Parser to avoid the usage of
eval().
> $telegram->getContactList();
array(13) {
  [...]
}
> $telegram->msg('my_contact', 'Hi, i am sending this from a php-client for telegram-cli.');
true
```

Documentation
-------------

[](#documentation)

To create the docs, just run `phpdoc` in the the project-root.
An online-version is available at [phpdoc.zyberware.org/zyberspace/telegram-cli-client](http://phpdoc.zyberware.org/zyberspace/telegram-cli-client/).

Supported Commands
------------------

[](#supported-commands)

You can execute every command with the `exec()`-method from the `RawClient`-class, but there are also several command-wrappers available ([doc-link](http://phpdoc.zyberware.org/zyberspace/telegram-cli-client/classes/Zyberspace.Telegram.Cli.Client.html)) that you should prefer to use (see the `example.php`).
If you prefer to only use your own command-wrappers instead, just extend the `RawClient`-class (takes care about the socket-connection and has some helper-methods).

In your command-wrappers or if you use `exec()` directly, please don't forget to escape the peers (contacts, chat-names, etc.) with `escapePeer()` and all string-arguments with `escapeStringArgument()` to avoid errors.

API-Stability
-------------

[](#api-stability)

The api of the commands wrappers will definitely change in the future, for example `getHistory()` only returns the raw answer of the telegram-cli right now and is not really useful. Therefore you should not use this in production yet.

**If you still want to use this in your project, make sure you stay at the same [minor](http://semver.org/spec/v2.0.0.html)-version (`~0.1.0` or `0.1.*` for example)**.

License
-------

[](#license)

This software is licensed under the [Mozilla Public License v. 2.0](http://mozilla.org/MPL/2.0/). For more information, read the file `LICENSE`.

###  Health Score

26

—

LowBetter than 43% of packages

Maintenance20

Infrequent updates — may be unmaintained

Popularity12

Limited adoption so far

Community11

Small or concentrated contributor base

Maturity53

Maturing project, gaining track record

 Bus Factor1

Top contributor holds 88.6% 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 ~179 days

Recently: every ~249 days

Total

7

Last Release

3022d ago

PHP version history (3 changes)v0.1.0PHP &gt;=5.4.0,&lt;6.0.0

v0.3.0PHP &gt;=5.3.0,&lt;6.0.0

v0.4.2PHP &gt;=5.3.0

### Community

Maintainers

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

---

Top Contributors

[![zyberspace](https://avatars.githubusercontent.com/u/2286104?v=4)](https://github.com/zyberspace "zyberspace (39 commits)")[![Alexsisukin](https://avatars.githubusercontent.com/u/17516588?v=4)](https://github.com/Alexsisukin "Alexsisukin (3 commits)")[![SikiFn](https://avatars.githubusercontent.com/u/2743862?v=4)](https://github.com/SikiFn "SikiFn (1 commits)")[![yorch81](https://avatars.githubusercontent.com/u/4605324?v=4)](https://github.com/yorch81 "yorch81 (1 commits)")

### Embed Badge

![Health badge](/badges/alexsisukin-php-telegram-cli-client/health.svg)

```
[![Health](https://phpackages.com/badges/alexsisukin-php-telegram-cli-client/health.svg)](https://phpackages.com/packages/alexsisukin-php-telegram-cli-client)
```

###  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.9M271](/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)[microsoft/microsoft-graph

The Microsoft Graph SDK for PHP

65723.5M96](/packages/microsoft-microsoft-graph)[meilisearch/meilisearch-php

PHP wrapper for the Meilisearch API

73813.7M114](/packages/meilisearch-meilisearch-php)

PHPackages © 2026

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