Why am I getting this error: Class "Google_Service_Calendar" not found?

Here is my code: this is just a sample of Google’s Quickstart.php:

require __DIR__ . '/vendor/autoload.php';


define('APPLICATION_NAME', 'Google Calendar API PHP Quickstart');
define('CREDENTIALS_PATH', '~/.credentials/calendar-php-quickstart.json');
define('CLIENT_SECRET_PATH', __DIR__ . '/client_secret.json');
define('SCOPES', implode(' ', array(
    Google_Service_Calendar::CALENDAR_READONLY)));

the last line throws this error: "class Google_Service_Calendar" was not found. Has anyone else experienced this?

+4
source share
1 answer

Works for me:

$ composer require google/apiclient:^2.0.0@RC
$ php -r 'require __DIR__ . "/vendor/autoload.php"; var_dump(Google_Service_Calendar::CALENDAR_READONLY);'
string(49) "https://www.googleapis.com/auth/calendar.readonly"

With this in mind, your startup is probably ruined. Give it a try composer dump-autoload.

Otherwise, you may be dependent on an older version of the API client that does not have this class. Try:

$ composer show -i | grep apiclient
google/apiclient    v2.0.0-RC4 Client library for Google APIs
+2
source

Source: https://habr.com/ru/post/1622226/


All Articles