PHPFixing
  • Privacy Policy
  • TOS
  • Ask Question
  • Contact Us
  • Home
  • PHP
  • Programming
  • SQL Injection
  • Web3.0

Monday, January 17, 2022

[FIXED] composer can not find classes and load them

 January 17, 2022     composer-php, namespaces, php     No comments   

Issue

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


Solution

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.



Answered By - Oscar Sortland Kolsrud
  • Share This:  
  •  Facebook
  •  Twitter
  •  Stumble
  •  Digg
Newer Post Older Post Home

0 Comments:

Post a Comment

Note: Only a member of this blog may post a comment.

Total Pageviews

Featured Post

Why Learn PHP Programming

Why Learn PHP Programming A widely-used open source scripting language PHP is one of the most popular programming languages in the world. It...

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments

Copyright © PHPFixing