Using a composer package inside a yii2 controller

I have installed a composer package using composer and i also checked if the packages are loaded in the index.php entry script and this is how it looks like

<?php

// comment out the following two lines when deployed to production
defined('YII_DEBUG') or define('YII_DEBUG', true);
defined('YII_ENV') or define('YII_ENV', 'dev');

require __DIR__ . '/../vendor/autoload.php';
require __DIR__ . '/../vendor/yiisoft/yii2/Yii.php';

$config = require __DIR__ . '/../config/web.php';

(new yii\web\Application($config))->run();

I have installed this package composer require php-http/curl-client typesense/typesense-php and i am using it in my controller

<?php

namespace app\controllers;


use Yii;
use yii\filters\AccessControl;
use yii\web\Controller;
use yii\web\Response;
use yii\filters\VerbFilter;
use yii\mongodb\Query;
use Symfony\Component\HttpClient\HttplugClient;
use Typesense\Client;

class UsersController extends Controller
{
	
public function init() 

{
$client = new Client(
        [
            'api_key' => '',
            'nodes' => [
                [
                    'host' => 'localhost',
                    'port' => '8108',
                    'protocol' => 'http',
                ],
            ],
            'client' => new HttplugClient(),
        ]
    );
}

I even replaced the init() with a constructor public function __construct() but i get this error

Class ‘Typesense\Client’ not found

on this line $client = new Client( Why is the class not being loaded? I have cheked and its present in my vendor directory.

I don’t see Typesense\Client in php-http/curl-client. There is something like that in typesense/typesense-php so maybe you’ve got that wrong? Always check what is inside a package.