There is no license information available for the latest version (dev-main) of this package.

Workspace for development and tests

dev-main 2022-03-24 20:32 UTC

This package is auto-updated.

Last update: 2024-03-25 01:09:25 UTC


Table of Contents
  1. About this repository
  2. Getting Started
  3. Using Docker
  4. Using the bot

About this repository

This repository is a boilerplate for development of the php-telegram-bot.

(back to top)

Getting Started

Cloning the repository

git clone --recurse-submodules

After cloning the workspace, you can use the workspace as if it were a project. We provided a few scripts and a docker-compose.yml that configures a webserver and a local Telegram Bot API server for using and testing webhooks.

Working on php-telegram-bot

To work on the php-telegram-bot repository itself you need to cd into the packages/php-telegram-bot directory and checkout a branch with

git checkout develop

To pull all the current changes from upstream you can call from any location

git submodule update --remote --merge

If you want to commit changes to upstream, you can simply do that as anywhere else.

(back to top)

Using Docker

By default the Docker setup launches preconfigured with the following containers:

  1. nginx Webserver
    • to accept webhook calls from the custom bot api server
  2. php-fpm PHP 8.1
    • runs all the code
  3. mariadb Database
    • already has the structure imported
  4. tdlight Custom Bot API Server
    • Lighter version of the custom Telegram bot API server.

To start the container copy the .env.example into a .env file and fill out your TELEGRAM_API_ID and TELEGRAM_API_HASH data from

After this you can start the containers with

docker-compose up -d

(back to top)

Using the bot

By default there is a /start command.

So if you've also filled out your TELEGRAM_BOT_USERNAME and TELEGRAM_BOT_TOKEN in your .env file, you can execute the setWebhook.php inside the php Docker container.

If successful, you should be able to send a /start to your bot.

(back to top)

Manually calling the webserver

If you need to call the webserver directly or have a look at the stats of the Bot API server you can create a docker-compose.override.yml file and add the needed port forwarding like in this example:

version: '3'
      - 8080:80
      TELEGRAM_STAT: yes
      - 8082:8082

The first block inside services extends the nginx service and adds a port forwarding from 8080 (on your host) to 80 inside the container. You can then call any php script or static files with http://localhost:8080

The second block extends the api-server service, enables the stats with an environment variable and forwards the port 8082 from the container to your host. This allows you to call http://localhost:8082 to access the stats page of the Telegram Bot API server and check i.e. if the webhook was registered correctly.