PHP: Google Service autoloader not finding classes

222 Views Asked by At

I have the following in my composer.json (unrelated packages not shown):

"require": {
    "googleads/googleads-php-lib": "^39.0",
    "google/apiclient": "2.7.2",
    "google/cloud-storage": "^1.23",
    "googleads/google-ads-php": "^14.0",
    "phpseclib/phpseclib": "2.0.31"
}

I have confirmed that the vender/autoload.php is being invoked. But when I use this code:

    $default_scope_set = array(
                                Google\Service\Plus::PLUS_LOGIN,
                                Google\Service\Plus::PLUS_ME,
                                Google\Service\Plus::USERINFO_EMAIL,
                              );

I get the error:

Error: Class 'Google\Service\Plus' not found in /home/httpd/idxv3/lib/GoogleAuthenticator.php:38

I just cannot figure out where I went wrong. Any thoughts?

1

There are 1 best solutions below

0
On

Ok, several changes have fixed my issues:

Moved away from Google+ references left over from this code's introduction years ago.

Changed underscore references to use namespaces

Upgraded old api-client to 2.12.1. I understand that there are 2 newer versions, but the google doc page for api-client is using 2.12.1, so I'll stick to that for now. My problems are resolved.