PHP code example of mk4u / tgram

1. Go to this page and download the library: Download mk4u/tgram library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

mk4u / tgram example snippets


return [
    'token'      => '110201543:AAHdqTcvCH1vGWJxfSeofSAs0K5PALDsaw',
    'secret'     => 'your_secret_token_here',
    'admins'     => [123456789, 985632147],
    'parse_mode' => 'HTML',
    'abs_path'   => __DIR__,
];



use Mk4U\TGram\Bot;

$bot = new Bot();
$bot->run();

namespace Bot\Commands;

use Mk4U\TGram\Core\Actions\Commands;
use Mk4U\TGram\Attributes\Command;

#[Command('/start')]
class Start extends Commands
{
    public function execute(): void
    {
        $this->reply('Hey there! Welcome to our bot!');
    }

    public static function description(): string
    {
        return 'Start Command to get you started';
    }
}
bash
php vendor/bin/tgram register
bash
     php vendor/bin/tgram hook:set https://your-domain.com/index.php
     
bash
     php vendor/bin/tgram poll