2

Already installed library using composer
Я уже установил библиотеку через composer

composer require vkcom/vk-php-sdk

But cant initializate it by
однако не выходит её инициализировать через

$vk = new VKApiClient();

Recieve error
Получаю ошибку

Fatal error: Uncaught Error: Class 'VKApiClient' not found in E:\OSPanel\domains\localhost\albom.php:2 Stack trace: #0 {main} thrown in E:\OSPanel\domains\localhost\albom.php on line 2 Directory hierarchy image
Изображение иерархии директорий

I already tried method below:
Также я пробовал способ ниже:

$vk = new \vkapi\src\VK\Client\VKApiClient();

But receive error:
Но получаю ошибку:

Fatal error: Uncaught Error: Class 'vkapi\src\VK\Client\VKApiClient' not found in E:\OSPanel\domains\localhost\albom.php:2 Stack trace: #0 {main} thrown in E:\OSPanel\domains\localhost\albom.php on line 2

Tried use require for composer autoload file, but it still doesnt works well
Уже пробовал использовать require для автозагрузочного файла composer'a, но это всё равно не работает

require '.\vendor\autoload.php';
$vk = new VKApiClient();

Recieve error
Получаю ошибку

Fatal error: Uncaught Error: Class 'VKApiClient' not found in E:\OSPanel\domains\localhost\albom.php:3 Stack trace: #0 {main} thrown in E:\OSPanel\domains\localhost\albom.php on line 3

t j
  • 7,026
  • 12
  • 46
  • 66
A Milky
  • 23
  • 4

1 Answers1

2

There are different points here.

First, VKApiClient's namespace is not \vkapi\src\VK\Client\. You can open a file and read the code. It doesn't contain src at all, it does contain namespace VK\Client, so you can initialize client this way

$vk = new \VK\Client\VKApiClient();

Second, you have to include source file. Composer does it via autoload.php. If is not actual somehow, try php composer dump-autoload to refresh autoload file.

Actually, you'd better use English only. Russian SO is here. Have you tried to ask your question there? Though audience is much greater here, I prefer English SO rather that Russian.

shukshin.ivan
  • 11,075
  • 4
  • 53
  • 69