I want to use aws-sdk
for php client in a custom module of drupal. I need to include vendor/autoload.php
in module. But when I include it, it gives me error. I have tried to include many ways but did not get success. I added it as:
require __DIR__.'/vendor/autoload.php';
at the top of the file of .module
file. Then the website gets crashed. Please could you tell how I should use require __DIR__.'/vendor/autoload.php';
I'm not sure about how drupal handles autoloading of external php modules. But with the experience of working with frameworks like laravel, cakephp and with composer, I'm sure that the target file which is index.php which routes to a number of different controllers in root directory already includes vendor/autoload.php. If it does not include, add the require statement which points to autoload.php relative to index.php or absolute path. Then using namespaces
in php, you can use external php modules which are then autoloaded.
require __DIR__.'/vendor/autoload.php'; // Incase vendor directory is in same level as index.php file
require dirname(__DIR__).'/vendor/autoload.php'; // Incase vendor directory is in parent level as index.php file