1. Go to this page and download the library: Download m4n50n/telegram-bot-bundle 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/ */
use M4n50n\TelegramBotBundle\Factory\TelegramBotFactory;
final class TelegramBotService
{
public function __construct(private TelegramBotFactory $botFactory)
{
}
public function initialize(string $botName)
{
// ...
return $this->botFactory->get($botName);
}
}
namespace App\Controller;
// ...
final class PHPCodeTesterBotController extends AbstractController
{
private readonly TelegramBot $bot;
public function __construct(private TelegramBotService $telegramBotService)
{
$this->bot = $telegramBotService->initialize("bot_name");
}
#[Route('/endpoint', name: 'app_webhook_endpoint')]
public function webhookEndpoint(): Response
{
// ...
$webhookHandler = $this->bot->webhookHandler();
// ... or
$setWebhook = $this->bot->setWebhook();
// ... or
$unsetWebhook = $this->bot->unsetWebhook();
// ...
}
}
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.