How to connect external library to my own extension?
Posted: Fri Oct 14, 2022 1:16 am
I added an external library to vendor directory.

And try to use this library in the controller but get an error "Error: Class "WeStacks\TeleBot\TeleBot" not found in /home/user/Coding/OC-Modules/x-telegram-notifications.loc/extension/x_telegram_notifications/catalog/controller/module/telegram_notifications.php on line 14".
Code of my controller:

My question is what is right approach to use external libraries in the controllers? Thank you in advance!

And try to use this library in the controller but get an error "Error: Class "WeStacks\TeleBot\TeleBot" not found in /home/user/Coding/OC-Modules/x-telegram-notifications.loc/extension/x_telegram_notifications/catalog/controller/module/telegram_notifications.php on line 14".
Code of my controller:
Code: Select all
<?php
namespace Opencart\Catalog\Controller\Extension\XTelegramNotifications\Module;
use Opencart\System\Engine\Controller;
use WeStacks\TeleBot\TeleBot;
class TelegramNotifications extends Controller
{
public function index(): void
{
error_reporting(E_ALL);
ini_set('display_errors', '1');
$telebot = new TeleBot(['token' => $this->getToken()]);
}
private function getToken(): string
{
return 'token';
}
}

My question is what is right approach to use external libraries in the controllers? Thank you in advance!