Post by xuborx » Fri Oct 14, 2022 1:16 am

I added an external library to vendor directory.
Image
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';
    }
}
Image

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

Newbie

Posts

Joined
Wed Jan 19, 2022 7:23 pm

Post by thekrotek » Fri Oct 14, 2022 12:20 pm

Why don't you want to use require() or require_once() functions?

Professional OpenCart extensions, support and custom work.
Contact me via email or Skype by support@thekrotek.com


User avatar
Expert Member

Posts

Joined
Sun Jul 03, 2016 12:24 am

Who is online

Users browsing this forum: No registered users and 5 guests