pCloud / pcloud-sdk-php

pCloud SDK for PHP
MIT License
54 stars 22 forks source link

Composer install and autoloaded pCloud not found. #20

Closed whitsey closed 2 years ago

whitsey commented 2 years ago

I had pCloud working fine but now have updated and everything has broken. So I have gone back to basics to try and start again.

Installed pCloud SDK:

Install the SDK

Using Composer

$ composer require pcloud/pcloud-php-sdk

Initialised SDK:

Initializing the SDK

The SDK uses an OAuth 2.0 access token to authorize requests to the pCloud API. You can obtain a token using the SDK's authorization flow. To allow the SDK to do that, find App Key, App secret and Redirect URIs in your application configuration page and add them to /example/code.php and /example/auth.php.

Note that redirect_uri is optional.

Run /example/code.php to get an authorization code and use this code in /example/auth.php. This will return access_token and locationid.

composer loaded from previous packages:

//Autoload composer require( ROOT_DIR . "vendor/autoload.php");

// Create File instance $pcloudFile = new pCloud\File();

PHP Fatal error:  Uncaught Error: Class 'pCloud\File' not found in \api\file.upload.cloud.php:10
Stack trace:
#0 {main}
  thrown in \api\file.upload.cloud.php on line 60

Pre-existing composer package PHPMailer is loaded and working fine from tests.

I added the following to the File: vendor/composer/ClassLoader.php In the function findFileWithExtension()

error_log("findFileWithExtension -- ".$class);

and it looks like it's only loadinh PHPMailer ;

findFileWithExtension -- PHPMailer\PHPMailer\PHPMailer

How do I get it to load pCLoud

Feedback from composer:

That's because the autoload configuration in the pcloud/pcloud-php-sdk is wrong. That should be reported to that package.

theroot79 commented 2 years ago

Hello @whitsey , we just submitted new release, branch 3.x , which many fixes and upgrades there. Please, check it out, It will cover all the problems you reported above in your comment.