I'm currently learning about autoload in php using composer and psr-4. i have successfully configured my composer.json and i can access classes using namespaces. Now, the problem is that i have to include vendor/autoload.php in every file that i want to use it in. It looks like this because of the structure i have in my project:
require("../../../vendor/autoload.php");
Is there a cleaner way to do this or avoid requiring it in every file?
I have tried with some things like creating a Global variable with that route, but it is not working. This is what i tried:
At the start of my index.php:
$GLOBAL["autoloadPath"]= $_SERVER['DOCUMENT_ROOT'] . '/ipa-crm/vendor/autoload.php';
Then i added this in every file that i needed:
require_once $GLOBAL["autoloadPath"];
Thanks in advance.