PHP Fatal error: Class 'Google Client' not found

PHP Fatal error: Class 'Google_Client' not found

1 문제상황[ | ]

root@zetawiki:~# cat google_test.php 
<?php
$client = new Google_Client();
var_dump( $client );
root@zetawiki:~# php google_test.php 
PHP Fatal error:  Class 'Google_Client' not found in /root/google_test.php on line 2

2 해결방법[ | ]

root@zetawiki:~# composer require google/apiclient
Using version ^2.1 for google/apiclient
./composer.json has been created
Loading composer repositories with package information
... (생략)
google/apiclient suggests installing cache/filesystem-adapter (For caching certs and tokens (using Google_Client::setCache))
Writing lock file
Generating autoload files
root@zetawiki:~# cat composer.lock | grep '"google/apiclient"'
            "name": "google/apiclient",
root@zetawiki:~/temp# ll vendor/ | grep google
drwxr-xr-x 5 root root 4096 Apr 11 00:27 google/

3 테스트[ | ]

root@zetawiki:~# vi google_test.php
<?php
require 'vendor/autoload.php';
$client = new Google_Client();
var_dump( $client );
root@zetawiki:~# php google_test.php | head -4
object(Google_Client)#2 (8) {
  ["auth":"Google_Client":private]=>
  NULL
  ["http":"Google_Client":private]=>

4 같이 보기[ | ]

문서 댓글 ({{ doc_comments.length }})
{{ comment.name }} {{ comment.created | snstime }}