Vendor classes not read

Hello everyone,
I am working with Yii1 in a vagrant environment and my vendor folder is outside the webroot. The challenge I am having is that when I require a new vendor package, vendor autoload does not read but when I move the vendor folder into the webroot, it reads the class. Please can anyone help me out with this cos the vendor folder needs to be outside the webroot.

Thanks

Check ur index.php … the entry point.
It should have something like this:
require __DIR__ '/../../vendor/autoload.php';
Means my index.php is in
/backend/web/index.php
And vendor is:
/vendor/...

Thanks for your response. the structure is
kumer/
yiiapp/
protected/
index.php
composer.json
composer.lock
vendor/

So in my index.php I have require_once DIR.’/…/vendor/autoload.php’ but for some reason it isn’t reading in all the classes.
I required vlucas/phpdotenv but when I call \Dotenv\Dotenv::create(…) it keeps saying Dotenv class not found and when i passed autoload to a variable to see what i was getting back Dotenv was not being autoloaded unless i put the vendor class inside yiiapp directory then it reads all the classes.

Show your index.php

Maybe you should change on ** require(DIR . ‘/vendor/autoload.php’);**, because vendor folder is under the same folder with index.php

My index and vendor are not in the same directory. Should have written it out like this
kumer/yiiapp/index.php
kumer/yiiapp/composer.json
kumer/yiiapp/composer.lock
kumer/vendor

This is my index.php
require_once __DIR__ . '/../vendor/autoload.php';

Yii:: createWebApplication ($config)->run();

Hi @valeriewil did you get any solution for this ??