Class "Google_Client" not found

I created a component:

<?php
    namespace common\components;
    use Google_Client;
    use Google_Service_Gmail;
    use Yii;
    use yii\base\ErrorException;
    use yii\helpers\ArrayHelper;
    use yii\base\Component;

    use yii\rest\ActiveController;
    use linslin\yii2\curl;



    class SocialLogin extends Component {
      public $GOOGLE_CLIENT_ID;
      public $FACEBOOK_CLIENT_ID;
      public $GOOGLE_CLIENT_ID_IOS;




      public function getGoogleUser($id_token,$device)
      {
            $clientID=$this->GOOGLE_CLIENT_ID;

            if($device=="ios")
            $clientID=$this->GOOGLE_CLIENT_ID_IOS;

            $client = new Google_Client(['client_id' => $clientID]);
            $payload = $client->verifyIdToken($id_token);
            if ($payload) {
                    // my code
            }

        }    

   }

      

Works fine on local, but on live server, I get the following error:

message ":" Class' Google_Client "not found",

What is the problem?

+3


source to share


2 answers


I solved the problem. The issue was PHP version

, it was PHP 7 on my local machine and on the server it was 5.6, then I updated PHP version and all problems went away.



+1


source


If you already need composer autoload.php and require the google/apiclient

composer package , you can search vendor/composer/autoload_static.php

for:

'Google_' => 
    array (
        0 => __DIR__ . '/..' . '/google/apiclient/src',
    ),

      



This is a google/apiclient

PSR-0 card , if you didn't find it or the path is wrong, it means that the package google/apiclient

is not installed correctly.

Hope this helps you.

+1


source







All Articles