Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Laravel: Class 'Google_Client' not found

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;

like image 825
zeref Avatar asked Jan 27 '26 03:01

zeref


1 Answers

Google_Client, Google_Service_YouTube etc are aliases to Google\Client and Google\Service\Youtube respectively. To import them, use:

use Google\Client as Google_Client;
use Google\Service\YouTube as Google_Service_YouTube;
like image 66
user22586865 Avatar answered Jan 28 '26 23:01

user22586865



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!