Dmytro Zarezenko
Dmytro Zarezenko

Reputation: 10686

Using composer autoload from subfolder

I have installed one package with composer by default to ./vendor/company/packagename. When I run scripts in root folder and include ./vendor/autoload.php all works good. But when I try run scripts from ./api/ subfolder and include ../vendor/autoload.php I received "Class not found" errors. So installed package not found as I see.

What can I do in this situation, how can I run scripts from sub-folders in this case?

Upvotes: 2

Views: 2000

Answers (1)

M. Sabev
M. Sabev

Reputation: 111

Try to include the autloader file from the api subfolder this way:

require __DIR__ . '/../vendor/autoload.php';

Upvotes: 4

Related Questions