1

I'm trying to use google-api-php-client in my laravel project.

I'm installed the package using "composer require google/apiclient" command and also added the following line in composer.json.

    {
       "autoload": {
            "classmap": [
                "vendor/google/apiclient/src/Google"
            ],
        }
    }

and run this command too "composer dump-autoload"

But whenever i try to create new Google Client object, it keeps returning fatal error : Google_Client not found.

Can anybody help me with this issue?.Thanks.

I have already tried following ways.
(1) use Google_Client;
(2) $client = new Google_Client;
(3) $client = new \Google_Client;

zeref
  • 146
  • 2
  • 8
  • remove this "vendor/google/apiclient/src/Google" and dump autoload again .no need this.i have tried it without that and its working fine – Vision Coderz May 31 '19 at 08:25
  • i used latest version from https://github.com/googleapis/google-api-php-client and laravel 5.8 – Vision Coderz May 31 '19 at 08:25
  • There really isn't any need to setup a class map when you install a package using composer. Because the package is installed in the vendor directory, it will be autoloaded by composer. If `composer dump` doesn't fix (although it should), try reinstalling the package. – Bogdan May 31 '19 at 08:30
  • I removed "vendor" line and autoload again.But still not works. I also tried deleting the whole vendor folder and reinstalled it.Still not helps... – zeref Jun 01 '19 at 06:43
  • 2
    I won't put this in as the definitive answer, but for me this worked: use \Google_Client; – Michael Hinds Sep 17 '20 at 07:32
  • @MichaelHinds Your suggestion also works for me too. Thanks! – Femzy Jul 10 '23 at 12:19

0 Answers0