abantecart / ups-php

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

Installation Issue - Class "UPS\OAuthClientCredentials\Configuration" not found #10

Closed crazyj9 closed 8 months ago

crazyj9 commented 8 months ago

Hi,

I'm having installation issues as well. I followed the instructions in this post and still cannot get past the error

Fatal error: Uncaught Error: Class "UPS\OAuthClientCredentials\Configuration" not found in /Users/crazyj9/Library/CloudStorage/Dropbox/Code/Sites/GMLapp/vendor/abantecart/ups-php/_examples/getAccessToken.php:10

Any other ideas to try?

Thank you! John

abolabo commented 8 months ago

did you tried this? https://github.com/abantecart/ups-php/issues/8#issuecomment-1837519483

crazyj9 commented 8 months ago

Yes, no luck.

abolabo commented 8 months ago

ups-php.zip try this

crazyj9 commented 8 months ago

That didn't work. Here's my controller with the code. Maybe I did something wrong?

`namespace App\Http\Controllers; require DIR . '/../../../vendor/autoload.php';

use Illuminate\Http\Request;

class UPSSaturdayDelivery extends Controller { public function SatCheck(Request $request) { //YOUR ACCOUNT NUMBER (6 characters) $accNumber = env('UPS_ACCOUNT_NUMBER', false); //UPS API Credentials (obtain after APP creation) $clientId = env('UPS_API_CLIENT_ID', false); $password = env('UPS_API_PASSWORD', false);

    $config = \UPS\OAuthClientCredentials\Configuration::getDefaultConfiguration()
        ->setUsername($clientId)
        ->setPassword($password);

    $apiInstance = new \UPS\OAuthClientCredentials\Request\DefaultApi(
    // If you want use custom http client, pass your client which implements `GuzzleHttp\ClientInterface`.
    // This is optional, `GuzzleHttp\Client` will be used as default.
        new \GuzzleHttp\Client(),
        $config
    );
    $grant_type = "client_credentials"; // string |
    $x_merchant_id = $accNumber; // string | Client merchant ID

    try {
        $result = $apiInstance->createToken($grant_type, $x_merchant_id);
        print_r($result);
    } catch (Exception $e) {
        echo 'Exception when calling DefaultApi->generateToken: ', $e->getMessage(), PHP_EOL;
    }
}

}`

abolabo commented 8 months ago

debug include path. var_dump( is_file(DIR . '/../../../vendor/autoload.php'));

crazyj9 commented 8 months ago

Thank you for the suggestion. The path is correct. Result is true. Could it be something in my autoload.php file then?

abolabo commented 8 months ago

Thank you for the suggestion. The path is correct. Result is true. Could it be something in my autoload.php file then?

Unfortunately, i cannot to resolve issue with composer-merge-plugin. It works different when you install this package via composer require shell command. It builds autoupload file without dependencies from subdirectories.

If you plan to use all APIs of UPS you should to download code from git and run composer install command to build common vendor directory for all UPS APIs.