2017-03-01 102 views
0

我想在012客戶端中使用aws-sdk在drupal的自定義模塊中。我需要在模塊中包含vendor/autoload.php。但是當我包含它時,它會給我錯誤。我試圖包含很多方法,但沒有取得成功。我將它添加爲:如何在模塊中包含自動加載drupal 7

require __DIR__.'/vendor/autoload.php';位於文件頂部的.module文件。然後該網站崩潰。請你能告訴我該如何使用require __DIR__.'/vendor/autoload.php';

+0

您需要爲模塊定義一個命名空間 – Fky

回答

0

我不確定drupal如何處理外部php模塊的自動加載。但有了使用像laravel,cakephp和composer等框架的經驗,我確信目錄文件是index.php,它指向根目錄中的許多不同控制器已經包含vendor/autoload.php。如果不包含,請將指向autoload.php的require語句添加到index.php或絕對路徑。然後在php中使用namespaces,你可以使用外部的php模塊,然後自動加載。

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