Class "Google_Config" not found

I try to implement the Google login API through the instructions here , but for some reason, when I try to start it, I always get:

Fatal error: Class 'Google_Config' not found in /home/.../Google/Client.php on line 76

I am sure that it is correctly connected with Client.php - I do not think this is a problem in my own code. Does anyone know what can happen here? Thanks!

+5
source share
6 answers

This error means that you did not use Composer to install the client. Without Composer, in a script you have to

set_include_path(get_include_path() . PATH_SEPARATOR . dirname($_SERVER['SCRIPT_FILENAME']) . 'vendor/google-api-php-client/src'); require_once '/path/to/autoload.php'; require_once '/path/to/Client.php'; 

Without autoload.php, the class will not be found. In Client.php, the code prior to class definition tries to load autoload.php. But you already found Client.php, providing the full path to it. Thus, autoload.php does not load.

As you say, your problem was solved when reinstalling the API. I suppose you used the composer a second time.

Explanation: The above note does NOT mean skipping the proper client installation, according to Google documentation . Applies to "google / apiclient": "1.0.*@beta"

+4
source

Are you sure that you downloaded the entire issue, not only the master thread from github? You must have / vendors and / src directories - then you need / src / autoload.php

+2
source

Google autoloader does not work for me, either because of the old version of PHP, or because of a conflict with a competing autoloader, I do not know.

I even tried manually, including googles autoloader (which should be redundant as src/Google/Client.php already require_once autoload.php :

 require_once 'google-api-php-client/autoload.php' require_once 'google-api-php-client/src/Google/Client.php' 

Google_Config never found ...

ultimatly the only solution is the solution described in fooobar.com/questions/1205452 / ... that is.

 set_include_path(get_include_path() . PATH_SEPARATOR . '/path/to/google-api-php-client/src'); require_once 'Google/Client.php' 
+1
source

I struggled with this for a while. The reason was pretty simple:

I ignored in git "config.php", which ignored this file and why it was not in my working environment.

0
source

I could solve the problem by following these steps:

 > cd "youfolder" > composer install 
0
source

Instead of saving the provider folder in the root folder, save it in the google-api-php-client-master folder and use the following line to include it in your project

require_once DIR .'/google-api-php-client-master/vendor/autoload.php';

0
source

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


All Articles