PHP code example of botgate / laravel

1. Go to this page and download the library: Download botgate/laravel 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/ */

    

botgate / laravel example snippets


use BotGate\Laravel\Facades\BotGate;

BotGate::bot('public-bot-id')->call('sendMessage', [
    'chat_id' => 123456789,
    'text' => 'Привет из Laravel!',
]);

BotGate::client(); // BotGate\Client
BotGate::config(); // BotGate\Config

use BotGate\DTO\UpdateType;
use BotGate\Laravel\Events\BotGateUpdateReceived;
use Illuminate\Support\Facades\Event;

Event::listen(function (BotGateUpdateReceived $event): void {
    $update = $event->update; // BotGate\DTO\Update

    if ($update->is(UpdateType::Message)) {
        $message = $update->message();
        // ваша логика
    }
});

use BotGate\Http\HttpClientInterface;

$this->app->bind(HttpClientInterface::class, function () {
    return new MyHttpClient(/* ... */);
});
bash
php artisan vendor:publish --tag=botgate-config