2015-09-07 64 views
2

我按照所有步驟運行PHP Google Calendar API。我跟着這個鏈接:https://developers.google.com/google-apps/calendar/quickstart/php。在步驟4,它要求以quickstart.php運行,但運行該文件後,它顯示我此錯誤:爲什麼我無法找到Google Calendar API的供應商/ autoload.php?

Warning: require(vendor/autoload.php): failed to open stream: No such file or directory in C:\xampp\htdocs\Calendar\google-api-php-client-master\quickstart.php on line 2

Fatal error: require(): Failed opening required 'vendor/autoload.php' (include_path='.;C:\xampp\php\PEAR') in C:\xampp\htdocs\Calendar\google-api-php-client-master\quickstart.php on line 2

+1

歡迎堆棧,請閱讀http://stackoverflow.com/help/how-to-ask – DaImTo

回答

1

下面是一個檢查表,你去打倒Composer和供應商/ autoload.php:

  • 您的composer.json文件是否存在於您的項目的根目錄中? (注意:這可能與您的Web服務器的文檔根目錄相同。)
  • vendor文件夾與您的composer.json存在於同一文件夾中嗎?
  • 您是否使用正確的相對路徑查找文件vendor/autoload.php

如果composer.json不在您的項目根目錄中,請將其移動到那裏。它屬於它的地方,直到它在那裏,事情將繼續出現問題。

當您運行php composer.phar installphp composer.phar update時,vendor文件夾及其autoload.php文件都會自動創建。如果他們錯過了,您需要運行php composer.phar install

確認vendor/autoload.php存在並位於正確的位置後,請確保您的require語句與該文件有良好的相對引用。

+0

你好@邁克爾,我是初學者,我安裝了作曲家在主目錄站立,所以它創建的文件夾供應商在主目錄中,所以在我使用'require vendor/autoload.php'的php中應該包含這個供應商文件夾,或者它可以自動提取? –

+0

所有這些命令,文件和文件夾應該存在於項目根文件夾中,而不是您的主文件夾。 –

0

我使用被跟隨命令解決此問題:

composer dump-autoload -o 

我將執行它的應用程序文件夾內。

例子:

c:\<<your_app_folder>>\composer dump-autoload -o. 

之後,你會看到 「供應商」 文件夾中。 autoload.php文件將在裏面。

For more information, access the link:
http://phpenthusiast.com/blog/how-to-autoload-with-composer

相關問題