abantecart / ups-php

PHP SDK to UPS RESTful API
MIT License
13 stars 9 forks source link

Fatal error: Uncaught Error: Class ‘UPS\OAuthClientCredentials\Configuration’ not found in / #19

Closed jav666 closed 3 months ago

jav666 commented 3 months ago

after composer install:

composer require abantecart/ups-php

i successfully installed everything and adjusted the credentials in

getAccessToken.php

and copy getAccessToken.php in root

unfortunately I only get:

Fatal error: Uncaught Error: Class ‘UPS\OAuthClientCredentials\Configuration’ not found in /var/www/getAccessToken.php

that's the simplest example, what's wrong with it?

danielpost commented 3 months ago

Did you include the Composer autoloader at the top of your file? require_once 'vendor/autoload.php';

jav666 commented 3 months ago

2024-05-28 12 54 31

yep.

jav666 commented 3 months ago

PHP version is 8.2.12

danielpost commented 3 months ago

@jav666 I can reproduce on my end. I'll do some research and see if I can fix it.

danielpost commented 3 months ago

@jav666 It seems like it can be fixed by adding this line:

require_once __DIR__ . '/vendor/abantecart/ups-php/vendor/autoload.php';

That being said, this seems like a bug that needs fixing—for some reason the classes do not get included in the normal autoloader. I suspect it has something to do with how composer-merge-plugin is implemented.

jav666 commented 3 months ago

but there is no "autoload.php" under this path '/vendor/abantecart/ups-php/vendor/autoload.php' ... and no "vendor" dir to

jav666 commented 3 months ago

just copy & paste?

jav666 commented 3 months ago

no, that doesn't work

danielpost commented 3 months ago

Hmm, there is for me. I did run composer update inside the ups-php folder, so it's possible the file didn't exist before that. Give it a try and see if that works.

jav666 commented 3 months ago

yes. works. ok, thank you very much!

danielpost commented 3 months ago

@abolabo If I may ask, what's the logic behind closing this as completed? It seems like there's some kind of bug in the autoloading logic, since you need to manually run composer update inside the package and include the nested autoloader file if you want to use this package.

The examples in their current form are broken.

abolabo commented 3 months ago

@danielpost there is bug in the composer require command which does not work with wikimedia merge-plugin. As you noted correctly classes from directories are ignored by composer bin during build.
If you download package from repo and run build with composer install command you will see your code will work fine. I don't know a solution for installation from packagist.org (command composer require ...) Probably you can suggest?

jav666 commented 3 months ago

ok, I had a look under ‘closed’ ... apparently everyone had the problem, because it didn't work from start to finish