duanfengshang1088 2019-02-01 22:26
浏览 89
已采纳

作曲家找不到类并加载它们

I am using a Dropbox api package and installed it with Composer.When I try to use classes that gives me a fatal error that can not find classes.

This is my composer.json

{
    "require": {
        "kunalvarma05/dropbox-php-sdk": "^0.2.1"
    }
}

This is my php file

use Kunnu\Dropbox\Dropbox;
use Kunnu\Dropbox\DropboxApp;

$app = new DropboxApp("client_id", "client_", 'access_token');

//Configure Dropbox service
$dropbox = new Dropbox($app);

//Get File Metadata
$fileMetadata = $dropbox->getMetadata("/helloworld.txt");

//File Name
// $fileMetadata->getName();

printf($fileMetadata->getName());

My php version is 7.2.4 and the error is:

Fatal error: Uncaught Error: Class 'Kunnu\Dropbox\DropboxApp' not found in D:\MeHDi\Projects\DropBox Api\Upload.php:6 Stack trace: #0 {main} thrown in D:\MeHDi\Projects\DropBox Api\Upload.php on line 6

  • 写回答

1条回答 默认 最新

  • dongtao5055 2019-02-01 23:36
    关注

    Have you remembered to import composers autoload file using require "path/to/vendor/autoload.php";

    This is required in order to initialize and use the different composer libraries. Remember to change the filepath to where your vendor/autoload.php file is located.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?